예제 #1
0
 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;
 }
예제 #2
0
        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++;
                }
            }
        }
예제 #3
0
 public RangeDuration(LogicFrameSpan min, LogicFrameSpan max)
 {
     Min = min;
     Max = max;
 }
예제 #4
0
 public RangeDuration(LogicFrameSpan value)
 {
     Min = Max = value;
 }
예제 #5
0
        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;
        }
예제 #6
0
 //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
 }
예제 #7
0
        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));
        }