Ejemplo n.º 1
0
        //no need for time variables because we're applying the value from the last update
        public float ApplyTo(StatusKeeper keeper, float valueWithFlow)
        {
            //get the actual flow last update
            //first align it with the target keeper's type
            //then apply multipliers
            float flowLastUpdate = StatusKeeper.GetSeekValue(keeper.ActiveState.SeekType, FlowType, FlowLastUpdate);

            flowLastUpdate = flowLastUpdate *= FlowMultiplier;
            switch (FlowType)
            {
            case StatusSeekType.Positive:
            default:
                flowLastUpdate *= Globals.StatusKeeperPositiveFlowMultiplier;
                break;

            case StatusSeekType.Neutral:
                //don't adjust flow
                break;

            case StatusSeekType.Negative:
                flowLastUpdate *= Globals.StatusKeeperNegativeFlowMultiplier;
                break;
            }
            //now apply it to the keeper's value
            //apply to the actual value not the normalized value
            //yes this can result in crazy flow stuff but that's OK
            return(valueWithFlow + flowLastUpdate);
        }
Ejemplo n.º 2
0
        public float ApplyTo(StatusKeeper keeper, double deltaTime)
        {
            Symptom symptom = null;

            if (mSymptomLookup.TryGetValue(keeper.Name, out symptom))                   //if it's active...
            {
                if (symptom.IsActive(TimeSoFar))
                {
                    //apply to the actual value not the normalized value
                    float currentValue = keeper.Value;
                    //get the ACTUAL seek value as it applies to this keeper's seek value type
                    float seekValue = StatusKeeper.GetSeekValue(keeper.ActiveState.SeekType, symptom.SeekType, symptom.SeekValue);
                    //apply the value to the current value
                    return(Mathf.Lerp(currentValue, symptom.SeekValue, (float)(symptom.SeekSpeed * deltaTime)));
                }
                else                            //if it's not active just return the untouched value
                {
                    return(keeper.Value);
                }
            }
            else
            {
                return(keeper.Value);
            }
        }
Ejemplo n.º 3
0
        public void RestoreStatus(float restore, string type)
        {
            StatusKeeper status = null;

            if (GetStatusKeeper(type, out status))
            {
                status.ChangeValue(restore, StatusSeekType.Positive);
            }
        }
Ejemplo n.º 4
0
        public override void OnLocalPlayerSpawn()
        {
            if (SpawnManager.Get.UseStartupPosition)
            {
                for (int i = 0; i < SpawnManager.Get.CurrentStartupPosition.StatusValues.Count; i++)
                {
                    StatusKeeper statusKeeper = null;
                    if (GetStatusKeeper(SpawnManager.Get.CurrentStartupPosition.StatusValues[i].StatusKeeperName, out statusKeeper))
                    {
                        statusKeeper.SetValue(SpawnManager.Get.CurrentStartupPosition.StatusValues[i].Value, false);
                    }
                }
            }

            RecentActions.Clear();

            for (int i = State.ActiveConditions.LastIndex(); i >= 0; i--)
            {
                if (State.ActiveConditions [i].HasExpired)
                {
                    State.ActiveConditions.RemoveAt(i);
                }
            }

            if (!mCheckingStatusKeepers)
            {
                mCheckingStatusKeepers = true;
                StartCoroutine(CheckStatusKeepers());
            }
            if (!mCheckingActiveConditions)
            {
                mCheckingActiveConditions = true;
                StartCoroutine(CheckActiveConditions());
            }
            if (!mCheckingEnvironment)
            {
                mCheckingEnvironment = true;
                StartCoroutine(CheckEnvironment());
            }

            StartCoroutine(CheckActiveStateList());

            for (int i = 0; i < State.ActiveConditions.Count; i++)
            {
                Condition activeCondition = State.ActiveConditions[i];
                for (int j = 0; j < StatusKeepers.Count; j++)
                {
                    StatusKeeper statusKeeper = StatusKeepers[j];
                    if (activeCondition.HasSymptomFor(statusKeeper.Name))                      //just add it to the conditions list
                    //don't bother with ReceiveCondition
                    //we'll check for expiration later
                    {
                        statusKeeper.Conditions.Add(activeCondition);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public void ReduceStatus(float reduce, string type)
        {
            StatusKeeper status = null;

            if (GetStatusKeeper(type, out status))
            {
                status.ChangeValue(reduce, StatusSeekType.Negative);
                if (status.Value < 0f)
                {
                    //we're taking away from something that's already really low
                    status.Ping = true;
                }
            }
        }
Ejemplo n.º 6
0
        public void LoadStatusKeepers()
        {
            StatusKeepers.Clear();
            List <string> statusKeeperNames = Mods.Get.ModDataNames("StatusKeeper");

            foreach (string statusKeeperName in statusKeeperNames)
            {
                StatusKeeper keeper = null;
                if (Mods.Get.Runtime.LoadMod <StatusKeeper>(ref keeper, "StatusKeeper", statusKeeperName))
                {
                    StatusKeepers.Add(keeper);
                }
            }
        }
Ejemplo n.º 7
0
        public override void OnGameLoadFinish()
        {
            HashSet <Condition> activeConditions = new HashSet <Condition>();

            mStatusKeeperLookup.Clear();
            List <string> StatusKeeperNames = Mods.Get.Available("StatusKeeper");

            for (int i = 0; i < StatusKeeperNames.Count; i++)
            {
                StatusKeeper statusKeeper = null;
                if (Mods.Get.Runtime.LoadMod <StatusKeeper>(ref statusKeeper, "StatusKeeper", StatusKeeperNames[i]))
                {
                    statusKeeper.Initialize();
                    mStatusKeeperLookup.Add(statusKeeper.Name, statusKeeper);
                    StatusKeepers.Add(statusKeeper);
                    if (statusKeeper.Name.Contains("Reputation"))
                    {
                        statusKeeper.DefaultState.UseNeutralUrgency = true;
                        foreach (StatusKeeperState state in statusKeeper.AlternateStates)
                        {
                            state.UseNeutralUrgency = true;
                        }
                    }
                    else if (statusKeeper.Name.Contains("Temperature"))
                    {
                        statusKeeper.DefaultState.UseNeutralUrgency = false;
                        foreach (StatusKeeperState state in statusKeeper.AlternateStates)
                        {
                            state.UseNeutralUrgency = false;
                        }
                    }
                }
            }
            StatusKeepers.Sort();
            //check to see whether the status value is zero
            StatusKeeper health = null;

            if (mStatusKeeperLookup.TryGetValue("Health", out health) && Mathf.Approximately(health.Value, 0f))
            {
                //if it's zero odds are the status keepers haven't been initialized to default values
                for (int i = 0; i < StatusKeepers.Count; i++)
                {
                    StatusKeepers[i].Reset();
                }
            }
        }
Ejemplo n.º 8
0
        public void AddCondition(string conditionName)
        {
            //Debug.Log ("Adding condition " + conditionName);
            bool conditionAdded = false;

            //first see if the condition is already present
            //if it is, don't clone the condition, stack it instead of creating a new one
            for (int i = 0; i < State.ActiveConditions.Count; i++)
            {
                Condition activeCondition = State.ActiveConditions[i];
                if (string.Equals(activeCondition.Name, conditionName) && !activeCondition.HasExpired)                  //double its duration so it'll last twice as long
                //Debug.Log ("Condition is already active, not adding new");
                {
                    activeCondition.IncreaseDuration(activeCondition.Duration * Globals.StatusKeeperTimecale);
                    return;
                }
            }

            Condition condition = null;

            if (Frontiers.Conditions.Get.ConditionByName(conditionName, out condition))                 //if we have no active conditions try looking it up
            //Debug.Log ("Condition found, adding now");
            {
                condition.Initialize();
                State.ActiveConditions.Add(condition);
                for (int i = 0; i < StatusKeepers.Count; i++)
                {
                    StatusKeeper statusKeeper = StatusKeepers [i];
                    if (condition.HasSymptomFor(statusKeeper.Name))
                    {
                        conditionAdded = true;
                        statusKeeper.ReceiveCondition(condition);
                    }
                }
            }
            else
            {
                //Debug.Log ("Condition " + conditionName + " not found");
            }

            if (conditionAdded)
            {
                Player.Get.AvatarActions.ReceiveAction(AvatarAction.SurvivalConditionAdd, WorldClock.RealTime);
            }
        }
Ejemplo n.º 9
0
 public void CheckForFlows()
 {
     mGatheredFlows.Clear();
     for (int i = 0; i < StatusKeepers.Count; i++)
     {
         StatusKeeper statusKeeper = StatusKeepers[i];
         StatusFlow   underflow    = null;
         StatusFlow   overflow     = null;
         if (statusKeeper.HasOverflowToSend(out overflow))
         {
             List <StatusFlow> flows = null;
             if (!mGatheredFlows.TryGetValue(overflow.TargetName, out flows))
             {
                 flows = new List <StatusFlow>();
                 mGatheredFlows.Add(overflow.TargetName, flows);
             }
             flows.Add(overflow);
         }
         if (statusKeeper.HasUnderflowToSend(out underflow))
         {
             List <StatusFlow> flows = null;
             if (!mGatheredFlows.TryGetValue(underflow.TargetName, out flows))
             {
                 flows = new List <StatusFlow>();
                 mGatheredFlows.Add(underflow.TargetName, flows);
             }
             flows.Add(underflow);
         }
     }
     //now that we've gathered all the flows
     //send them to the status keepers
     for (int i = 0; i < StatusKeepers.Count; i++)
     {
         StatusKeeper      statusKeeper = StatusKeepers[i];
         List <StatusFlow> flows        = null;
         if (mGatheredFlows.TryGetValue(statusKeeper.Name, out flows))
         {
             statusKeeper.ReceiveFlows(flows);
         }
     }
 }
Ejemplo n.º 10
0
        protected IEnumerator CheckStatusKeepers()
        {
            while (mCheckingStatusKeepers)
            {
                while (GameManager.Get.JustLookingMode)
                {
                    yield return(null);
                }

                while (player.IsDead || !player.HasSpawned)
                {
                    //wait until we're not dead
                    yield return(null);
                }

                double deltaTime = WorldClock.ARTDeltaTime * Globals.StatusKeeperTimecale;
                for (int i = 0; i < StatusKeepers.Count; i++)
                {
                    StatusKeeper statusKeeper = StatusKeepers[i];
                    statusKeeper.UpdateState(deltaTime);
                    statusKeeper.ApplyConditions(deltaTime, RecentActions, State.ActiveConditions, ActiveStateList);
                    if (Globals.StatusKeeperNegativeFlowMultiplier > 0 || Globals.StatusKeeperPositiveFlowMultiplier > 0)
                    {
                        statusKeeper.ApplyStatusFlows(deltaTime);
                    }
                    //are we dead?
                    if (statusKeeper.Name.Equals("Health"))
                    {
                        if (statusKeeper.NormalizedValue <= 0f)
                        {
                            //we're dead! try to die here
                            player.Die(string.Empty);
                        }
                    }
                }
                yield return(null);
            }
            mCheckingStatusKeepers = false;
            yield break;
        }
Ejemplo n.º 11
0
 public bool GetStatusKeeper(string statusKeeperName, out StatusKeeper statusKeeper)
 {
     return(mStatusKeeperLookup.TryGetValue(statusKeeperName, out statusKeeper));
 }