예제 #1
0
 public abstract void Init(MyObjectBuilder_AiTarget builder);
예제 #2
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);
                }
            }
        }