Commit Graph

54 Commits

Author SHA1 Message Date
reaperrr
b0e90989a6 Add plumbing for customizable vertical ProximityTrigger range
And check DistanceAboveTerrain instead of just vertical distance to upgrade
source.
This is necessary to avoid situations where an actor is technically on the right
vertical distance above/below ground, but not upgraded because it is located on a lower/higher terrain level than the upgrade source.
2016-05-26 22:47:45 +02:00
Paul Chote
e79fbe1bb9 Reference SubCells directly from MapGrid. 2016-03-16 18:57:07 +00:00
Paul Chote
e71225496b Clarify GPL version. 2016-02-21 16:30:48 +00:00
Paul Chote
b396965fd9 Update licence header year. 2016-02-21 16:27:31 +00:00
RoosterDragon
b0619a3e25 Added comments in performance sensitive code. 2015-12-13 16:24:54 +00:00
RoosterDragon
c0286bb147 Remove ActorMap.ActorsInWorld.
Prefer the more direct and efficient query on World.Actors instead.
2015-12-12 20:42:44 +00:00
reaperrr
2f69711341 Rename ActorMap *UnitsAt* occurences to *ActorsAt*
These enumerate actors in general, not just mobile actors (which the term 'unit' usually refers to).
2015-10-16 00:07:06 +02:00
RoosterDragon
dab53f403d Provide a hand-written enumerator for ActorMap.GetUnitsAt(CPos). 2015-08-31 20:43:19 +01:00
RoosterDragon
18478646d4 Avoid multiple ToMPos calls in ActorMap. 2015-08-31 20:43:18 +01:00
Pavel Penev
7701980b76 Simple code style cleanups 2015-07-28 14:21:17 +03:00
Paul Chote
2b3c65334d Correct Contains check in ActorMap. 2015-07-27 18:43:51 +01:00
David Jiménez
5109848215 Changes to improve understandability of code 2015-07-18 15:05:12 +02:00
Matthias Mailänder
56e9bcd96e rename RangeSquard to LengthSquared 2015-07-09 21:16:01 +02:00
Matthias Mailänder
7447e0bf93 rename WRange to WDist 2015-07-09 10:55:38 +02:00
Oliver Brakmann
206c33ed41 Merge pull request #8226 from pchote/actor-disposal
Dispose traits when destroying an actor.
2015-06-02 19:33:22 +02:00
Matthias Mailänder
ea5003cd2d add new long WRange.RangeSquared to avoid integer overflows 2015-05-31 23:51:30 +02:00
Paul Chote
585a43fd8f Rename Actor.Destroy/Destroyed to Dispose/Disposed. 2015-05-29 19:08:38 +01:00
abcdefg30
8ca61aa917 Updated all year numbers 2015-01-09 21:18:05 +01:00
Oliver Brakmann
58dc61e6ed Merge pull request #7262 from RoosterDragon/actormap-partitioning
Fix ActorMap spatial partitioning to actually work.
2015-01-04 18:48:01 +01:00
Oliver Brakmann
75808c365a Merge pull request #7269 from abcdefg30/general-polish
Some general polish
2015-01-04 16:54:37 +01:00
Matthias Mailänder
bc3acfeee7 StyleCop clean OpenRA.Game 2015-01-04 15:38:54 +01:00
abcdefg30
f2e224dd72 Fix a crash in RemoveProximityTrigger 2015-01-04 13:06:06 +01:00
RoosterDragon
a0737ccbf3 Fix ActorMap spatial partitioning to actually work.
The bin partitioning in ActorMap worked by dividing the map up into a few chunks of cells, each of which would contain some actors. Unfortunately, the bins were accessed directly in world coordinates which are on a scale 1024x greater than cell coordinates. This lead to all actors being placed into the bottom right bin. When checking for actors in a box, only this bottom right bin would be iterated for actors. Thanks to the fact this bin indeed contained all the actors, some clamps on the input ranges and filtering required per bin anyway, this actually returned correct results. Effectively, it was as if there was no spatial partitioning at all.

Not surprisingly however, this is fairly inefficient. By correcting the spatial partitioning to actually partition we see a 7x speedup in ActorsInBox on the RA shellmap.
2015-01-04 02:35:16 +00:00
Hellhake
5a97a4b63b Fix StyleCop warnings in OpenRA.Game 2015-01-02 12:11:01 +01:00
abcdefg30
e29adf5f4f Added proximity triggers 2014-11-23 13:31:39 +01:00
Guido L.
ae4ee0926a AnyUnitsAt: Ignore destroyed Units 2014-11-09 03:15:33 +01:00
Paul Chote
0652d338f8 Add proximity trigger plumbing. 2014-10-04 14:01:45 +13:00
Paul Chote
a61fdba44d Implement cell triggers. Closes #4400. 2014-09-30 19:25:09 +13:00
Paul Chote
ee77db1831 Add some additional robustness against bogus cell queries in ActorMap. 2014-09-24 22:36:59 +12:00
Matthias Mailänder
44d134afe0 don't update the actor map outside the map borders 2014-09-21 10:52:44 +02:00
atlimit8
8ad1140921 Reduce ICrushable trait lookup & drop -SubCell suffix.
Replace `a.HasTrait<ICrushable>()` with a.TraitsImplementing<ICrushable>().Any() or equivalent.
2014-08-30 04:43:57 -05:00
atlimit8
e29b9edfc1 Changes to map.cs, rename IPositionable.IsLeaving{ => Cell}, add IPositionable.GetValidSubCell 2014-08-29 23:30:16 -05:00
atlimit8
63c28ee4d7 Refactored in new enum SubCell 2014-08-29 23:00:53 -05:00
atlimit8
27ad5208fb Fixed Mobile.SetPosition & other FixUnloadCargo touch-ups
Fixed Mobile.SetPosition
Finally removed old SubCell enum
Folded MobileInfo.CanEnterCell overloads into one
Renamed IPositionable.{IsMovingFrom => IsLeaving}
Changed Crate.IsLeaving to use crate lifetime
2014-08-29 23:00:53 -05:00
atlimit8
b2c9064545 Refactored [sub-]cell availability logic in IPositionable & ActorMap
Moved the logic from IPositionable.CanEnterCell & integrated sub-cell selection.
Added IPositionable.IsMovingFrom(CPos location, int subCell = -1) - to detect transient actors
Renamed IPositionable.{GetDesiredSubcell => GetAvailableSubcell} - since it checks for available sub-cells
Reduced IPositionable.CanEnterCell to one method that usually uses IPositionable.GetAvailableSubcell
Added actor checking to ActorMap.{HasFreeSubCell, FreeSubCell, AnyUnitsAt} - used by [sub-]cell availability logic
2014-08-29 23:00:53 -05:00
atlimit8
fe57417aa8 Added int subCell = -1 to IMove.MoveIntoWorld & IPositionable.SetPosition(Actor self, CPos cell) 2014-08-29 23:00:53 -05:00
atlimit8
898bf4959a Remove sub-cell offset bounds checking 2014-08-04 18:09:26 -05:00
atlimit8
9b30c21f93 Load subcells and default subcell index from mod.yaml 2014-08-04 18:09:26 -05:00
atlimit8
43478dd500 enum SubCell => int & Dictionary<SubCell, WVec> => WVec[] 2014-08-04 18:09:26 -05:00
RoosterDragon
ffd2e8ea9d Sped up ActorMap.ActorsInBox.
- By ensuring both the add and remove actor lists are sets, we ensure the partitioning bins will contain only distinct actors. We can remove the HashSet and Distinct in ActorsInBox and ActorsInWorld which provides a nice speedup for queries. ActorsInBox sees nearly a 3x speedup in the RA shellmap.
2014-07-09 18:43:40 +01:00
Paul Chote
5560f276ca Map: Rename IsInMap -> Contains. 2014-06-27 22:07:03 +12:00
Paul Chote
8dc0967d2e Use CellLayer for ActorMap. 2014-06-27 22:07:02 +12:00
Paul Chote
bbd1331536 Clean up actor selection in WorldInteractionControllerWidget. 2014-06-27 19:20:44 +12:00
RoosterDragon
8a60880cf1 Tackle the last of the low hanging fruit for memory allocations in the main game loop.
- Avoid calling string.Split twice in SprintFont.Measure.
- Change ActorsInBox method of ActorMap and ScreenMap to avoid allocating and intermediate list. As a bonus this allows the sequence to be lazily consumed. Also avoid LINQ in these methods.
- In FrozenUnderFog.TickRender, the method exits early if no players are visible so the attempt at lazy generation was not needed.
- Unwrap a LINQ Any call in ClassicProductionQueue.Tick.
- Merge some successive Where calls in ProximityCapturable into single predicates.
2014-06-22 17:29:45 +01:00
ScottNZ
dbffce81a6 Remove unused usings 2014-06-15 22:16:40 +12:00
RoosterDragon
b8b8b1e2df Minor changes to reduce allocation.
- Cache a predicate in ActorMap.
- Use short circuiting to skip a call to HasTrait in AttackBase.
- In AutoTarget.ScanForTarget, move the check for the scan time above the calculations since we can skip them if it's not time yet.
- In AutoTarget.ChooseTarget, merge four Where calls into one.
2014-06-12 05:32:44 +01:00
RoosterDragon
2bd8778c55 Changed removeActorPosition field in ActorMap into a set.
This is because it's purpose is to be queried via Contains when actors needed to be removed.
2014-05-23 08:30:45 +01:00
ScottNZ
00ec1ca87a Remove unused usings 2013-11-12 19:39:33 +13:00
Paul Chote
4f354e1474 Batch ActorMap add/removes and filter invalid ActorsInBox. Fixes #3897. 2013-10-05 13:19:47 +13:00
Paul Chote
85f854ccde Clean up ActorMap. 2013-10-05 12:59:54 +13:00