예제 #1
0
    public static bool CheckFaction(int EntityID, EntityAlive entity)
    {
        bool        result   = false;
        EntityAlive myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAlive;

        if (myEntity == null)
        {
            return(result);
        }

        // same faction
        if (myEntity.factionId == entity.factionId)
        {
            return(true);
        }

        FactionManager.Relationship myRelationship = FactionManager.Instance.GetRelationshipTier(myEntity, entity);
        DisplayLog(" CheckFactionForEnemy: " + myRelationship.ToString());
        if (myRelationship == FactionManager.Relationship.Hate)
        {
            DisplayLog(" I hate this entity: " + entity.ToString());
            return(false);
        }
        else
        {
            DisplayLog(" My relationship with this " + entity.ToString() + " is: " + myRelationship.ToString());
            result = true;
        }
        return(false);
    }
예제 #2
0
    public bool CheckSurroundingEntities()
    {
        this.NearbyEntities.Clear();
        EntityAlive leader = null;

        if (this.theEntity.Buffs.HasCustomVar("Leader"))
        {
            DisplayLog(" leader Detected.");
            int EntityID = (int)this.theEntity.Buffs.GetCustomVar("Leader");
            leader = this.theEntity.world.GetEntity(EntityID) as EntityAlive;
        }

        if (leader == null)
        {
            DisplayLog(" No leader detected.");
            return(false);
        }

        // Search in the bounds are to try to find the most appealing entity to follow.
        Bounds bb = new Bounds(this.theEntity.position, new Vector3(this.theEntity.GetSeeDistance(), 20f, this.theEntity.GetSeeDistance()));

        this.theEntity.world.GetEntitiesInBounds(typeof(EntityAlive), bb, this.NearbyEntities);
        DisplayLog(" Nearby Entities: " + this.NearbyEntities.Count);
        for (int i = this.NearbyEntities.Count - 1; i >= 0; i--)
        {
            EntityAlive x = (EntityAlive)this.NearbyEntities[i];
            if (x != this.theEntity)
            {
                DisplayLog("Nearby Entity: " + x.EntityName);
                if (x.GetAttackTarget() == leader)
                {
                    DisplayLog(" My leader is being attacked by " + x.ToString());
                    targetEntity = x;
                    this.theEntity.SetRevengeTarget(targetEntity);
                    return(true);
                }

                if (x.GetRevengeTarget() == leader)
                {
                    DisplayLog(" My leader is being avenged by " + x.ToString());
                    targetEntity = x;
                    this.theEntity.SetRevengeTarget(targetEntity);

                    return(true);
                }

                if (x.GetDamagedTarget() == leader)
                {
                    DisplayLog(" My leader is being attacked by something that damaged it " + x.ToString());
                    targetEntity = x;
                    this.theEntity.SetRevengeTarget(targetEntity);

                    return(true);
                }
            }
        }

        return(false);
    }
예제 #3
0
    public bool CheckSurroundingEntities()
    {
        this.NearbyEntities.Clear();
        EntityAlive leader = EntityUtilities.GetLeaderOrOwner(this.theEntity.entityId) as EntityAlive;

        if (!leader)
        {
            return(false);
        }

        // Search in the bounds are to try to find the most appealing entity to follow.
        Bounds bb = new Bounds(this.theEntity.position, new Vector3(this.theEntity.GetSeeDistance(), 20f, this.theEntity.GetSeeDistance()));

        //Bounds bb = new Bounds(this.theEntity.position, new Vector3(20f, 20f,20f));
        this.theEntity.world.GetEntitiesInBounds(typeof(EntityAlive), bb, this.NearbyEntities);
        DisplayLog(" Nearby Entities: " + this.NearbyEntities.Count);
        for (int i = this.NearbyEntities.Count - 1; i >= 0; i--)
        {
            EntityAlive x = (EntityAlive)this.NearbyEntities[i];
            if (x != this.theEntity)
            {
                if (x.IsDead())
                {
                    continue;
                }

                DisplayLog("Nearby Entity: " + x.EntityName);
                if (x.GetAttackTarget() == leader)
                {
                    DisplayLog(" My leader is being attacked by " + x.ToString());
                    targetEntity = x;
                    this.theEntity.SetRevengeTarget(targetEntity);
                    return(true);
                }

                if (x.GetRevengeTarget() == leader)
                {
                    DisplayLog(" My leader is being avenged by " + x.ToString());
                    targetEntity = x;
                    this.theEntity.SetRevengeTarget(targetEntity);

                    return(true);
                }

                if (x.GetDamagedTarget() == leader)
                {
                    DisplayLog(" My leader is being attacked by something that damaged it " + x.ToString());
                    targetEntity = x;
                    this.theEntity.SetRevengeTarget(targetEntity);

                    return(true);
                }
            }
        }

        return(false);
    }
예제 #4
0
 public bool CheckFactionForEnemy(EntityAlive Entity)
 {
     FactionManager.Relationship myRelationship = FactionManager.Instance.GetRelationshipTier(this.theEntity, Entity);
     if (myRelationship == FactionManager.Relationship.Hate)
     {
         DisplayLog(" I hate this entity: " + Entity.ToString());
         return(true);
     }
     else
     {
         DisplayLog(" My relationship with this " + Entity.ToString() + " is: " + myRelationship.ToString());
     }
     return(false);
 }
예제 #5
0
    public static bool NearestEnemy(EntityAlive theEntity, List <Entity> NearbyEnemies)
    {
        if (NearbyEnemies.Count == 0)
        {
            return(false);
        }

        // Finds the closet block we matched with.
        EntityAlive closeEnemy = null;
        float       minDist    = Mathf.Infinity;
        Vector3     currentPos = theEntity.position;

        foreach (EntityAlive enemy in NearbyEnemies)
        {
            float dist = Vector3.Distance(enemy.position, currentPos);
            DisplayLog(" Entity: " + enemy.EntityName + "'s distance is: " + dist);
            if (dist < minDist)
            {
                closeEnemy = enemy;
                minDist    = dist;
            }
        }

        if (closeEnemy != null)
        {
            DisplayLog(" Closes Enemy: " + closeEnemy.ToString());
            theEntity.SetRevengeTarget(closeEnemy);
            return(true);
        }
        return(false);
    }
예제 #6
0
    public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
    {
        if (_params.Count < 3)
        {
            SingletonMonoBehaviour <SdtdConsole> .Instance.Output("You need to use 3 parameters: [Entity ID] [Stat Name] [Stat Value]");

            return;
        }

        if (!supportedStats.Contains(_params[1].ToLower()))
        {
            SingletonMonoBehaviour <SdtdConsole> .Instance.Output(_params[1] + "is not a valid Entity Stat");

            return;
        }

        int id;

        if (int.TryParse(_params[0], out id))
        {
            Entity entity = null;
            for (int i = GameManager.Instance.World.Entities.list.Count - 1; i >= 0; i--)
            {
                Entity curEntity = GameManager.Instance.World.Entities.list[i];
                if (curEntity.entityId == id)
                {
                    entity = curEntity;
                    break;
                }
            }
            if (entity == null || !entity.GetType().IsSubclassOf(typeof(EntityAlive)))
            {
                SingletonMonoBehaviour <SdtdConsole> .Instance.Output("Not a valid entity");

                return;
            }

            EntityAlive entityAlive = (EntityAlive)entity;

            float value;
            if (float.TryParse(_params[2], out value))
            {
                // special case to modify the wetness level of an entity
                if (_params[1].ToLower() == "waterlevel")
                {
                    entityAlive.Stats.SetWaterLevel(value);
                }
                // all other stats
                else
                {
                    SingletonMonoBehaviour <SdtdConsole> .Instance.Output(entityAlive.ToString() + ": Setting Stat " + _params[1] + " to " + _params[2]);

                    entityAlive.Stats.SetValue(_params[1].ToLower(), value);
                }
            }
        }
        else
        {
            SingletonMonoBehaviour <SdtdConsole> .Instance.Output("Entity '" + _params[0] + "' not found");
        }
    }