Ejemplo n.º 1
0
 public static void RemoveController(LifeStatsController controller)
 {
     if (agentControllers.Contains(controller))
     {
         agentControllersDump.Add(controller);
     }
 }
Ejemplo n.º 2
0
 public static void AddController(LifeStatsController controller)
 {
     if (!agentControllers.Contains(controller))
     {
         controllersQueue.Add(controller);
     }
 }
Ejemplo n.º 3
0
            public static void ResetAgentStats(LifeStatsController controller)
            {
                List <int> keys = controller.ChaControl.fileGameInfo.flavorState.Keys.ToList();

                foreach (int key in keys)
                {
                    controller.agent.AgentData.SetFlavorSkill(key, 0);
                }

                controller.agent.SetPhase(0);

                controller.ChaControl.fileGameInfo.lifestyle = -1;

                List <int> skillKeys = controller.ChaControl.fileGameInfo.normalSkill.Keys.ToList();

                foreach (int key in skillKeys)
                {
                    controller.ChaControl.fileGameInfo.normalSkill.Remove(key);
                }

                List <int> hSkillKeys = controller.ChaControl.fileGameInfo.hSkill.Keys.ToList();

                foreach (int key in hSkillKeys)
                {
                    controller.ChaControl.fileGameInfo.hSkill.Remove(key);
                }
            }
Ejemplo n.º 4
0
            public static void PenalizeAgentStats(LifeStatsController controller)
            {
                List <int> keys = controller.ChaControl.fileGameInfo.flavorState.Keys.ToList();

                foreach (int key in keys)
                {
                    if (key == (int)FlavorSkill.Type.Wariness || key == (int)FlavorSkill.Type.Darkness)
                    {
                        controller.agent.AgentData.SetFlavorSkill(key, controller.agent.GetFlavorSkill(key) + 200);
                    }
                    else
                    {
                        controller.agent.AgentData.SetFlavorSkill(key, controller.agent.GetFlavorSkill(key) - 200);
                    }
                }

                int phase = controller.ChaControl.fileGameInfo.phase;

                if (phase > 0)
                {
                    controller.agent.SetPhase(phase - 1);
                }

                if (phase <= 3)
                {
                    controller.ChaControl.fileGameInfo.lifestyle = -1;
                }

                List <int> skillKeys = controller.ChaControl.fileGameInfo.normalSkill.Keys.ToList();

                foreach (int key in skillKeys)
                {
                    if (UnityEngine.Random.Range(1, 100) <= 20)
                    {
                        controller.ChaControl.fileGameInfo.normalSkill.Remove(key);
                    }
                }

                List <int> hSkillKeys = controller.ChaControl.fileGameInfo.hSkill.Keys.ToList();

                foreach (int key in hSkillKeys)
                {
                    if (UnityEngine.Random.Range(1, 100) <= 20)
                    {
                        controller.ChaControl.fileGameInfo.hSkill.Remove(key);
                    }
                }
            }
Ejemplo n.º 5
0
            static void WarningCheck(LifeStatsController controller, int threshold)
            {
                float stat = controller["health"];

                if (agentWarn.Contains(controller))
                {
                    if (stat > threshold)
                    {
                        agentWarn.Remove(controller);
                    }
                }
                else if (stat <= threshold)
                {
                    agentWarn.Add(controller);

                    string name        = controller.agent.CharaName;
                    string preposition = stat < threshold ? "below" : "at";

                    MapUIContainer.AddNotify($"{name}'s health is {preposition} {threshold}%!");
                }
            }
Ejemplo n.º 6
0
            private static void UpdateAgent(LifeStatsController controller, float hourDelta)
            {
                if (AgentDeath.Value == DeathType.None)
                {
                    return;
                }

                if (controller["health"] > 0)
                {
                    bool healthLoss = false;

                    if (controller.agent.StateType == State.Type.Collapse)
                    {
                        controller["health"] -= AgentHealthLoss.Value * hourDelta;
                        healthLoss            = true;
                    }

                    if (controller.agent.AgentData.StatsTable[(int)AIProject.Definitions.Status.Type.Hunger] <= AgentLowFood.Value)
                    {
                        controller["health"] -= AgentHealthLossHunger.Value * hourDelta;
                        healthLoss            = true;
                    }

                    var thirstLevel = 100 - controller.agent.AgentData.DesireTable[15];
                    controller["water"] -= 5.357f * hourDelta;
                    if (thirstLevel > 35 && controller["water"] < thirstLevel)
                    {
                        controller["water"] = thirstLevel;
                    }

                    if (controller["water"] <= AgentLowWater.Value)
                    {
                        controller["health"] -= AgentHealthLossThirst.Value * hourDelta;
                        healthLoss            = true;
                    }

                    switch (controller.agent.AgentData.SickState.ID)
                    {
                    case AIProject.Definitions.Sickness.ColdID: controller["health"] -= AgentHealthLossCold.Value * hourDelta; healthLoss = true; break;

                    case AIProject.Definitions.Sickness.HeatStrokeID: controller["health"] -= AgentHealthLossHeat.Value * hourDelta; healthLoss = true; break;

                    case AIProject.Definitions.Sickness.HurtID: controller["health"] -= AgentHealthLossHurt.Value * hourDelta; healthLoss = true; break;

                    case AIProject.Definitions.Sickness.StomachacheID: controller.agent.AgentData.StatsTable[(int)AIProject.Definitions.Status.Type.Hunger] -= AgentFoodLossStomachache.Value * hourDelta; break;

                    case AIProject.Definitions.Sickness.OverworkID: controller.agent.AgentData.StatsTable[(int)AIProject.Definitions.Status.Type.Physical] -= AgentStaminaLossOverwork.Value * hourDelta; break;
                    }

                    if (!healthLoss)
                    {
                        if ((controller.agent.StateType == State.Type.Sleep || controller.agent.StateType == State.Type.Immobility))
                        {
                            controller["health"] += AgentHealthRate.Value * hourDelta * 3;
                        }
                        else
                        {
                            controller["health"] += AgentHealthRate.Value * hourDelta;
                        }
                    }

                    if (controller["health"] == 0)
                    {
                        if (AgentDeath.Value == DeathType.PermaDeath)
                        {
                            TryDelete(controller.agent.ChaControl);
                        }

                        if (AgentDeath.Value == DeathType.Incapacitated)
                        {
                            MapUIContainer.AddNotify($"{controller.agent.CharaName} is incapacitated.");
                        }
                        else
                        {
                            MapUIContainer.AddNotify($"{controller.agent.CharaName} died.");
                        }
                    }
                }
                else if (AgentDeath.Value == DeathType.Incapacitated && controller.agent.StateType == State.Type.Immobility)
                {
                    controller["revive"] += 100f * hourDelta / 24f;

                    if (controller["revive"] >= 100)
                    {
                        controller["water", "stamina", "health"] = 100f;
                        controller["revive"] = 0;

                        if (AgentRevivePenalty.Value == RevivePenalty.StatReset)
                        {
                            ResetAgentStats(controller);
                        }
                        else if (AgentRevivePenalty.Value == RevivePenalty.StatLoss)
                        {
                            PenalizeAgentStats(controller);
                        }

                        MapUIContainer.AddNotify($"{controller.agent.CharaName} has been revived.");
                    }
                }
            }