internal CastleBehavior(GameObject gameObject, GameContext context, CastleBehaviorModuleData moduleData) { IsUnpacked = false; _moduleData = moduleData; _gameObject = gameObject; _context = context; _updateInterval = new LogicFrameSpan((uint)MathF.Ceiling(Game.LogicFramesPerSecond / 2)); // 0.5s _nativePlayer = _gameObject.Owner; }
public void EnqueuePayload(ProductionUpdate productionUpdate, LogicFrameSpan delay) { _productionUpdate = productionUpdate; foreach (var rank in _formation.Values) { foreach (var position in rank) { _productionUpdate.SpawnPayload(position.Definition, delay); _pendingRegistrations++; } } }
public RangeDuration(LogicFrameSpan min, LogicFrameSpan max) { Min = min; Max = max; }
public RangeDuration(LogicFrameSpan value) { Min = Max = value; }
internal static void CheckForStructure(BehaviorUpdateContext context, GameObject obj, ref LogicFrame waitUntil, LogicFrameSpan interval) { if (context.LogicFrame < waitUntil) { return; } waitUntil = context.LogicFrame + interval; var collidingObjects = context.GameContext.Game.PartitionCellManager.QueryObjects( obj, obj.Translation, obj.Geometry.BoundingCircleRadius, new PartitionQueries.KindOfQuery(ObjectKinds.Structure)); if (collidingObjects.Any()) { obj.IsSelectable = false; obj.Hidden = true; return; } obj.IsSelectable = true; obj.Hidden = false; }
//TODO: rather notify this when the corresponding order is processed and update again when the object is dead/destroyed internal FoundationAIUpdate(GameObject gameObject, FoundationAIUpdateModuleData moduleData) : base(gameObject, moduleData) { _moduleData = moduleData; _updateInterval = new LogicFrameSpan((uint)MathF.Ceiling(Game.LogicFramesPerSecond / 2)); // 0.5s, we do not have to check every frame }
private static LogicFrameSpan GetDelayWithVariance(BehaviorUpdateContext context, LogicFrameSpan delay, LogicFrameSpan variance) { var randomMultiplier = (context.GameContext.Random.NextDouble() * 2.0) - 1.0; return(delay + (variance * (float)randomMultiplier)); }