Exemplo n.º 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;
 }
Exemplo n.º 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++;
                }
            }
        }
Exemplo n.º 3
0
 public RangeDuration(LogicFrameSpan min, LogicFrameSpan max)
 {
     Min = min;
     Max = max;
 }
Exemplo n.º 4
0
 public RangeDuration(LogicFrameSpan value)
 {
     Min = Max = value;
 }
Exemplo n.º 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;
        }
Exemplo n.º 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
 }
Exemplo n.º 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));
        }