Example #1
0
        public void SetTargetCube(Vector3I blockPosition, long entityId)
        {
            TargetType = MyAiTargetEnum.CUBE;
            EntityId = entityId;
			TreeId = null;
            Position = new Vector3D(blockPosition);
        }
Example #2
0
		public void SetTargetTree(Vector3D treePosition, long entityId, long treeId)
		{
			TargetType = MyAiTargetEnum.ENVIRONMENT_ITEM;
			EntityId = entityId;
			TreeId = treeId;
			Position = treePosition;
		}
Example #3
0
        public void SetTargetPosition(Vector3D position)
        {
            TargetType = MyAiTargetEnum.POSITION;
            EntityId = null;
			TreeId = null;
            Position = position;
        }
Example #4
0
        public void SetTargetEntity(MyAiTargetEnum targetType, long entityId)
        {
            TargetType = targetType;
            EntityId = entityId;
			TreeId = null;
            Position = null;
        }
Example #5
0
		public MyBBMemoryTarget(Vector3D position, long environmentId, long itemId)
		{
			TargetType = MyAiTargetEnum.ENVIRONMENT_ITEM;
			EntityId = environmentId;
			TreeId = itemId;
			Position = position;
		}
 public static void SetTargetEntity(ref MyBBMemoryTarget target, MyAiTargetEnum targetType, long entityId, Vector3D? position = null)
 {
     if (target == null) target = new MyBBMemoryTarget();
     target.TargetType = targetType;
     target.EntityId = entityId;
     target.TreeId = null;
     target.Position = position;
 }
Example #7
0
        public MyAiTargetBase(IMyEntityBot bot)
        {
            m_user          = bot;
            m_bot           = bot as MyAgentBot;
            m_currentTarget = MyAiTargetEnum.NO_TARGET;

            MyAiTargetManager.AddAiTarget(this);
        }
Example #8
0
        public MyAiTargetBase(IMyEntityBot bot)
        {
            m_user = bot;
            m_bot = bot as MyAgentBot;
            m_currentTarget = MyAiTargetEnum.NO_TARGET;

            MyAiTargetManager.Static.AddAiTarget(this);
        }
        public void SetTargetVoxel(Vector3D pos, MyVoxelMap voxelMap)
        {
            UnsetTarget();

            MyVoxelCoordSystems.WorldPositionToVoxelCoord(voxelMap.PositionLeftBottomCorner, ref pos, out m_targetInVoxelCoord);
            SetMTargetPosition(pos);
            m_currentTarget = MyAiTargetEnum.VOXEL;
        }
Example #10
0
 public void SetTargetBlock(MySlimBlock slimBlock, ushort?compoundId = new ushort?())
 {
     if (!ReferenceEquals(this.m_targetEntity, slimBlock.CubeGrid))
     {
         this.SetTargetEntity(slimBlock.CubeGrid);
     }
     this.m_targetCube    = slimBlock.Position;
     this.m_currentTarget = MyAiTargetEnum.CUBE;
 }
Example #11
0
 private void Clear()
 {
     this.m_currentTarget      = MyAiTargetEnum.NO_TARGET;
     this.m_targetEntity       = null;
     this.m_targetCube         = Vector3I.Zero;
     this.m_targetPosition     = Vector3D.Zero;
     this.m_targetInVoxelCoord = Vector3I.Zero;
     this.m_compoundId         = null;
     this.m_targetTreeId       = 0;
 }
Example #12
0
 protected virtual void UnsetTargetEntity()
 {
     if (this.IsTargetGridOrBlock(this.m_currentTarget) && (this.m_targetEntity is MyCubeGrid))
     {
         (this.m_targetEntity as MyCubeGrid).OnBlockRemoved -= new Action <MySlimBlock>(this.BlockRemoved);
     }
     this.m_compoundId    = null;
     this.m_targetEntity  = null;
     this.m_currentTarget = MyAiTargetEnum.NO_TARGET;
 }
Example #13
0
 private void Clear()
 {
     m_currentTarget = MyAiTargetEnum.NO_TARGET;
     m_targetEntity = null;
     m_targetCube = Vector3I.Zero;
     m_targetPosition = Vector3D.Zero;
     m_targetInVoxelCoord = Vector3I.Zero;
     m_compoundId = null;
     m_targetTreeId = 0;
 }
Example #14
0
 public static void SetTargetEntity(ref MyBBMemoryTarget target, MyAiTargetEnum targetType, long entityId, Vector3D?position = null)
 {
     if (target == null)
     {
         target = new MyBBMemoryTarget();
     }
     target.TargetType = targetType;
     target.EntityId   = entityId;
     target.TreeId     = null;
     target.Position   = position;
 }
Example #15
0
        public void SetTargetBlock(MySlimBlock slimBlock, ushort?compoundId = null)
        {
            if (m_targetEntity != slimBlock.CubeGrid)
            {
                // We don't have to unset the target, because it will be done in SetTargetEntity
                SetTargetEntity(slimBlock.CubeGrid);
            }

            m_targetCube    = slimBlock.Position;
            m_currentTarget = MyAiTargetEnum.CUBE;
        }
Example #16
0
        public void SetTargetBlock(MySlimBlock slimBlock, ushort?compoundId = null)
        {
            if (m_targetEntity != slimBlock.CubeGrid)
            {
                UnsetTarget();
                SetTargetEntity(slimBlock.CubeGrid);
            }

            m_targetCube = slimBlock.Position;


            m_currentTarget = MyAiTargetEnum.CUBE;
        }
Example #17
0
        protected virtual void UnsetTargetEntity()
        {
            Debug.Assert(m_targetEntity != null);

            if (IsTargetGridOrBlock(m_currentTarget) && m_targetEntity is MyCubeGrid)
            {
                var grid = m_targetEntity as MyCubeGrid;
                grid.OnBlockRemoved -= BlockRemoved;
            }

            m_compoundId    = null;
            m_targetEntity  = null;
            m_currentTarget = MyAiTargetEnum.NO_TARGET;
        }
Example #18
0
        protected virtual void SetTargetEntity(MyEntity entity)
        {
            if (entity == null)
            {
                if (m_targetEntity != null)
                {
                    UnsetTargetEntity();
                }
                return;
            }

            if (entity is MyCubeBlock)
            {
                SetTargetBlock((entity as MyCubeBlock).SlimBlock);
            }
            else
            {
                UnsetTarget();

                m_targetEntity = entity;

                if (entity is MyCubeGrid)
                {
                    (entity as MyCubeGrid).OnBlockRemoved += BlockRemoved;
                    m_currentTarget = MyAiTargetEnum.GRID;
                }
                else if (entity is MyCharacter)
                {
                    m_currentTarget = MyAiTargetEnum.CHARACTER;
                }
                else if (entity is MyVoxelBase)
                {
                    m_currentTarget = MyAiTargetEnum.VOXEL;
                }
                else if (entity is MyEntity)
                {
                    m_currentTarget = MyAiTargetEnum.ENTITY;
                }
            }
        }
Example #19
0
        public virtual void Init(MyObjectBuilder_AiTarget builder)
        {
            m_currentTarget = builder.CurrentTarget;

            m_targetEntity = null;
            if (builder.EntityId.HasValue)
            {
                if (!MyEntities.TryGetEntityById(builder.EntityId.Value, out m_targetEntity))
                {
                    m_currentTarget = MyAiTargetEnum.NO_TARGET;
                }
            }
            else
            {
                m_currentTarget = MyAiTargetEnum.NO_TARGET;
            }

            m_targetCube     = builder.TargetCube;
            m_targetPosition = builder.TargetPosition;
            m_compoundId     = builder.CompoundId;

            if (builder.UnreachableEntities != null)
            {
                foreach (var data in builder.UnreachableEntities)
                {
                    MyEntity entity = null;
                    if (MyEntities.TryGetEntityById(data.UnreachableEntityId, out entity))
                    {
                        m_unreachableEntities.Add(entity, MySandboxGame.TotalGamePlayTimeInMilliseconds + data.Timeout);
                    }
                    else
                    {
                        Debug.Assert(false, "Couldn't find entity with given id: " + data.UnreachableEntityId);
                    }
                }
            }
        }
Example #20
0
        public void SetTargetVoxel(Vector3D pos, MyVoxelMap voxelMap)
        {
            UnsetTarget();

            MyVoxelCoordSystems.WorldPositionToVoxelCoord(voxelMap.PositionLeftBottomCorner, ref pos, out m_targetInVoxelCoord);
            SetMTargetPosition(pos);
            m_currentTarget = MyAiTargetEnum.VOXEL;
        }
Example #21
0
 public void SetTargetPosition(Vector3D pos)
 {
     UnsetTarget();
     SetMTargetPosition(pos);
     m_currentTarget = MyAiTargetEnum.POSITION;
 }
Example #22
0
        public void SetTargetBlock(MySlimBlock slimBlock, ushort? compoundId = null)
        {
            if (m_targetEntity != slimBlock.CubeGrid)
            {
                // We don't have to unset the target, because it will be done in SetTargetEntity
                SetTargetEntity(slimBlock.CubeGrid);
            }

            m_targetCube = slimBlock.Position;
            m_currentTarget = MyAiTargetEnum.CUBE;
        }
Example #23
0
        protected virtual void UnsetTargetEntity()
        {
            Debug.Assert(m_targetEntity != null);

            if (IsTargetGridOrBlock(m_currentTarget) && m_targetEntity is MyCubeGrid)
            {
                var grid = m_targetEntity as MyCubeGrid;
                grid.OnBlockRemoved -= BlockRemoved;
            }

            m_compoundId = null;
            m_targetEntity = null;
            m_currentTarget = MyAiTargetEnum.NO_TARGET;
        }
Example #24
0
        protected virtual void SetTargetEntity(MyEntity entity)
        {
            if (entity is MyCubeBlock)
            {
                SetTargetBlock((entity as MyCubeBlock).SlimBlock);
            }
            else
            {
                if (m_targetEntity != null)
                    UnsetTargetEntity();
                m_targetEntity = entity;

                if (entity is MyCubeGrid)
                {
                    (entity as MyCubeGrid).OnBlockRemoved += BlockRemoved;
                    m_currentTarget = MyAiTargetEnum.GRID;
                }
                else if (entity is MyCharacter)
                {
                    m_currentTarget = MyAiTargetEnum.CHARACTER;
                }
                else if (entity is MyVoxelBase)
                {
                    m_currentTarget = MyAiTargetEnum.VOXEL;
                }
                else if (entity is MyEnvironmentItems)
                {
                    m_currentTarget = MyAiTargetEnum.ENVIRONMENT_ITEM;
                }
                else if (entity is MyEntity)
                {
                    m_currentTarget = MyAiTargetEnum.ENTITY;
                }
            }
        }
Example #25
0
 public void SetTargetPosition(Vector3D position)
 {
     TargetType = MyAiTargetEnum.POSITION;
     EntityId   = null;
     Position   = position;
 }
Example #26
0
 public void SetTargetEntity(MyAiTargetEnum targetType, long entityId)
 {
     TargetType = targetType;
     EntityId   = entityId;
     Position   = null;
 }
Example #27
0
 public void SetTargetCube(Vector3I blockPosition, long entityId)
 {
     TargetType = MyAiTargetEnum.CUBE;
     EntityId   = entityId;
     Position   = new Vector3D(blockPosition);
 }
 public MyAiTargetBase(IMyEntityBot bot)
 {
     m_user = bot;
     m_bot = bot as MyAgentBot;
     m_currentTarget = MyAiTargetEnum.NO_TARGET;
 }
Example #29
0
 public virtual void UnsetTarget()
 {
     m_currentTarget = MyAiTargetEnum.NO_TARGET;
     m_targetEntity = null;
 }
Example #30
0
        public void SetTargetBlock(MySlimBlock slimBlock, ushort? compoundId = null)
        {
            if (m_targetEntity != slimBlock.CubeGrid)
            {
                UnsetTarget();
                SetTargetEntity(slimBlock.CubeGrid);
            }

            m_targetCube = slimBlock.Position;


            m_currentTarget = MyAiTargetEnum.CUBE;
        }
Example #31
0
 public MyBBMemoryTarget(MyAiTargetEnum targetType, long entityId)
 {
     SetTargetEntity(targetType, entityId);
 }
Example #32
0
 public virtual void UnsetTarget()
 {
     m_currentTarget = MyAiTargetEnum.NO_TARGET;
     m_targetEntity  = null;
 }
Example #33
0
 public bool IsTargetGridOrBlock(MyAiTargetEnum type)
 {
     return(type == MyAiTargetEnum.CUBE || type == MyAiTargetEnum.GRID);
 }
Example #34
0
 public void SetTargetPosition(Vector3D pos)
 {
     UnsetTarget();
     m_targetPosition = pos;
     m_currentTarget  = MyAiTargetEnum.POSITION;
 }
Example #35
0
 public bool IsTargetGridOrBlock(MyAiTargetEnum type) =>
 ((type == MyAiTargetEnum.CUBE) || (type == MyAiTargetEnum.GRID));
Example #36
0
 public MyAiTargetBase(IMyEntityBot bot)
 {
     m_user          = bot;
     m_bot           = bot as MyAgentBot;
     m_currentTarget = MyAiTargetEnum.NO_TARGET;
 }
Example #37
0
 public void SetTargetPosition(Vector3D pos)
 {
     this.UnsetTarget();
     this.SetMTargetPosition(pos);
     this.m_currentTarget = MyAiTargetEnum.POSITION;
 }
Example #38
0
 public bool IsTargetGridOrBlock(MyAiTargetEnum type)
 {
     return type == MyAiTargetEnum.CUBE || type == MyAiTargetEnum.GRID;
 }
Example #39
0
        public virtual void Init(MyObjectBuilder_AiTarget builder)
        {
            m_currentTarget = builder.CurrentTarget;

            m_targetEntity = null;
            if (builder.EntityId.HasValue)
            {
                if (!MyEntities.TryGetEntityById(builder.EntityId.Value, out m_targetEntity))
                {
                    m_currentTarget = MyAiTargetEnum.NO_TARGET;
                }
            }
            else
            {
                m_currentTarget = MyAiTargetEnum.NO_TARGET;
            }

            m_targetCube = builder.TargetCube;
            SetMTargetPosition(builder.TargetPosition);
            m_compoundId = builder.CompoundId;

            if (builder.UnreachableEntities != null)
            {
                foreach (var data in builder.UnreachableEntities)
                {
                    MyEntity entity = null;
                    if (MyEntities.TryGetEntityById(data.UnreachableEntityId, out entity))
                        m_unreachableEntities.Add(entity, MySandboxGame.TotalGamePlayTimeInMilliseconds + data.Timeout);
                    else
                        Debug.Assert(false, "Couldn't find entity with given id: " + data.UnreachableEntityId);
                }
            }
        }
Example #40
0
 public MyBBMemoryTarget(MyAiTargetEnum targetType, long entityId)
 {
     SetTargetEntity(targetType, entityId);
 }