Пример #1
0
    public override void EndExecution(Entity stateEntity, ActionContext action, Otto actor)
    {
        base.EndExecution(stateEntity, action, actor);

        foreach (var domainObjectEntity in actor.GetObjectEntities(stateEntity, typeof(Inventory)))
        {
            var inventory = actor.GetObjectTrait <Inventory>(domainObjectEntity);
            inventory.Amount -= inventory.ConsumableType == m_ConsumableType ? 1 : 0;
            actor.SetObjectTrait(domainObjectEntity, inventory);
        }

        foreach (var domainObjectEntity in actor.GetObjectEntities(stateEntity, typeof(Need)))
        {
            var need = actor.GetObjectTrait <Need>(domainObjectEntity);
            need.Urgency -= need.NeedType == m_NeedType ? m_NeedReduction : 0;
            actor.SetObjectTrait(domainObjectEntity, need);
        }
    }
Пример #2
0
    public override void EndExecution(Entity stateEntity, ActionContext action, Otto actor)
    {
        foreach (var domainObjectEntity in actor.GetObjectEntities(stateEntity, typeof(Inventory)))
        {
            var inventory = actor.GetObjectTrait <Inventory>(domainObjectEntity);
            inventory.Amount += inventory.ConsumableType == m_ConsumableType ? 1 : 0;
            actor.SetObjectTrait(domainObjectEntity, inventory);
        }

        base.EndExecution(stateEntity, action, actor);
    }
Пример #3
0
    void SetNeeds(Entity stateEntity)
    {
        foreach (var domainObjectEntity in m_Otto.GetObjectEntities(stateEntity, typeof(Need)))
        {
            var need = m_Otto.GetObjectTrait <Need>(domainObjectEntity);

            if (need.NeedType == NeedType.Hunger)
            {
                m_HungerMat.SetFloat(s_Amount, 1 - need.Urgency / 100f);
            }
            else if (need.NeedType == NeedType.Thirst)
            {
                m_ThirstMat.SetFloat(s_Amount, 1 - need.Urgency / 100f);
            }
            else if (need.NeedType == NeedType.Fatigue)
            {
                m_FatigueMat.SetFloat(s_Amount, 1 - need.Urgency / 100f);
            }
        }
    }
Пример #4
0
    public override void BeginExecution(Entity stateEntity, ActionContext action, Otto actor)
    {
        base.BeginExecution(stateEntity, action, actor);

        m_Animator = actor.GetComponentInParent <Animator>();
        m_Animator.SetTrigger(Animator.StringToHash("Sleep"));

        // Reset fatigue.
        foreach (var domainObjectEntity in actor.GetObjectEntities(stateEntity, typeof(Need)))
        {
            var need = actor.GetObjectTrait <Need>(domainObjectEntity);
            if (need.NeedType == NeedType.Fatigue)
            {
                need.Urgency = 0;
                actor.SetObjectTrait(domainObjectEntity, need);
                break;
            }
        }
    }