示例#1
0
        public void SetTargetCube(Vector3I blockPosition, long entityId)
        {
            TargetType = MyAiTargetEnum.CUBE;
            EntityId = entityId;
			TreeId = null;
            Position = new Vector3D(blockPosition);
        }
示例#2
0
		public void SetTargetTree(Vector3D treePosition, long entityId, long treeId)
		{
			TargetType = MyAiTargetEnum.ENVIRONMENT_ITEM;
			EntityId = entityId;
			TreeId = treeId;
			Position = treePosition;
		}
示例#3
0
        public void SetTargetPosition(Vector3D position)
        {
            TargetType = MyAiTargetEnum.POSITION;
            EntityId = null;
			TreeId = null;
            Position = position;
        }
示例#4
0
        public void SetTargetEntity(MyAiTargetEnum targetType, long entityId)
        {
            TargetType = targetType;
            EntityId = entityId;
			TreeId = null;
            Position = null;
        }
示例#5
0
		public MyBBMemoryTarget(Vector3D position, long environmentId, long itemId)
		{
			TargetType = MyAiTargetEnum.ENVIRONMENT_ITEM;
			EntityId = environmentId;
			TreeId = itemId;
			Position = position;
		}
示例#6
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;
 }
示例#7
0
        public MyAiTargetBase(IMyEntityBot bot)
        {
            m_user          = bot;
            m_bot           = bot as MyAgentBot;
            m_currentTarget = MyAiTargetEnum.NO_TARGET;

            MyAiTargetManager.AddAiTarget(this);
        }
示例#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;
        }
示例#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;
 }
示例#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;
 }
示例#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;
 }
示例#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;
 }
示例#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;
 }
示例#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;
        }
示例#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;
        }
示例#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;
        }
示例#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;
                }
            }
        }
示例#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);
                    }
                }
            }
        }
示例#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;
        }
示例#21
0
 public void SetTargetPosition(Vector3D pos)
 {
     UnsetTarget();
     SetMTargetPosition(pos);
     m_currentTarget = MyAiTargetEnum.POSITION;
 }
示例#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;
        }
示例#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;
        }
示例#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;
                }
            }
        }
示例#25
0
 public void SetTargetPosition(Vector3D position)
 {
     TargetType = MyAiTargetEnum.POSITION;
     EntityId   = null;
     Position   = position;
 }
示例#26
0
 public void SetTargetEntity(MyAiTargetEnum targetType, long entityId)
 {
     TargetType = targetType;
     EntityId   = entityId;
     Position   = null;
 }
示例#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;
 }
示例#29
0
 public virtual void UnsetTarget()
 {
     m_currentTarget = MyAiTargetEnum.NO_TARGET;
     m_targetEntity = null;
 }
示例#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;
        }
示例#31
0
 public MyBBMemoryTarget(MyAiTargetEnum targetType, long entityId)
 {
     SetTargetEntity(targetType, entityId);
 }
示例#32
0
 public virtual void UnsetTarget()
 {
     m_currentTarget = MyAiTargetEnum.NO_TARGET;
     m_targetEntity  = null;
 }
示例#33
0
 public bool IsTargetGridOrBlock(MyAiTargetEnum type)
 {
     return(type == MyAiTargetEnum.CUBE || type == MyAiTargetEnum.GRID);
 }
示例#34
0
 public void SetTargetPosition(Vector3D pos)
 {
     UnsetTarget();
     m_targetPosition = pos;
     m_currentTarget  = MyAiTargetEnum.POSITION;
 }
示例#35
0
 public bool IsTargetGridOrBlock(MyAiTargetEnum type) =>
 ((type == MyAiTargetEnum.CUBE) || (type == MyAiTargetEnum.GRID));
示例#36
0
 public MyAiTargetBase(IMyEntityBot bot)
 {
     m_user          = bot;
     m_bot           = bot as MyAgentBot;
     m_currentTarget = MyAiTargetEnum.NO_TARGET;
 }
示例#37
0
 public void SetTargetPosition(Vector3D pos)
 {
     this.UnsetTarget();
     this.SetMTargetPosition(pos);
     this.m_currentTarget = MyAiTargetEnum.POSITION;
 }
示例#38
0
 public bool IsTargetGridOrBlock(MyAiTargetEnum type)
 {
     return type == MyAiTargetEnum.CUBE || type == MyAiTargetEnum.GRID;
 }
示例#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);
                }
            }
        }
示例#40
0
 public MyBBMemoryTarget(MyAiTargetEnum targetType, long entityId)
 {
     SetTargetEntity(targetType, entityId);
 }