Ejemplo n.º 1
0
        public override void ExitState()
        {
            base.ExitState();

            ai?.Dispose();
            ai = null;
            buff?.RemoveAndDisposeCompanionBuff();
            buff = null;
            combatWithheldDialogue?.Clear();
            combatWithheldDialogue = null;
            seenDialogueForLocations?.Clear();
            seenDialogueForLocations = null;
            r = null;
            Patches.companion = null;

            ModEntry.modHelper.Events.GameLoop.UpdateTicked -= GameLoop_UpdateTicked;
            ModEntry.modHelper.Events.GameLoop.TimeChanged  -= GameLoop_TimeChanged;
            ModEntry.modHelper.Events.GameLoop.DayEnding    -= GameLoop_DayEnding;

            ModEntry.modHelper.Events.Player.Warped -= Player_Warped;

            ModEntry.modHelper.Events.Display.MenuChanged -= Display_MenuChanged;

            ModEntry.modHelper.Events.World.NpcListChanged -= World_NpcListChanged;
        }
Ejemplo n.º 2
0
        public override void Entry()
        {
            this.ai = new AI_StateMachine(this.StateMachine.Companion, this.StateMachine.CompanionManager.Farmer, this.Events, this.StateMachine.Monitor);

            this.StateMachine.Companion.faceTowardFarmerTimer = 0;
            this.StateMachine.Companion.movementPause         = 0;
            this.StateMachine.Companion.followSchedule        = false;
            this.StateMachine.Companion.Schedule            = null;
            this.StateMachine.Companion.controller          = null;
            this.StateMachine.Companion.temporaryController = null;
            this.StateMachine.Companion.eventActor          = true;
            this.StateMachine.Companion.farmerPassesThrough = true;

            this.Events.GameLoop.UpdateTicked += this.GameLoop_UpdateTicked;
            this.Events.GameLoop.TimeChanged  += this.GameLoop_TimeChanged;
            this.Events.Player.Warped         += this.Player_Warped;

            if (this.BuffManager.HasAssignableBuffs())
            {
                this.BuffManager.AssignBuffs();
            }
            else
            {
                this.StateMachine.Monitor.Log($"Companion {this.StateMachine.Name} has no buffs defined!", LogLevel.Alert);
            }

            if (DialogueHelper.GetVariousDialogueString(this.StateMachine.Companion, "companionRecruited", out string dialogueText))
            {
                this.StateMachine.Companion.setNewDialogue(dialogueText);
            }
            this.CanCreateDialogue = true;

            this.ai.Setup();
        }
Ejemplo n.º 3
0
        public override void EnterState()
        {
            base.EnterState();

            ai = new AI_StateMachine(this);
            combatWithheldDialogue = new Stack <Dialogue>();
            buff = CompanionBuff.InitializeBuffFromCompanionName(stateMachine.companion.Name, stateMachine.manager.farmer,
                                                                 stateMachine.manager);
            seenDialogueForLocations = new Dictionary <string, bool>();
            r = new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed + Game1.timeOfDay);
            Patches.companion = stateMachine.companion.Name;
            stateMachine.companion.faceTowardFarmerTimer = 0;
            stateMachine.companion.movementPause         = 0;

            stateMachine.companion.controller          = null;
            stateMachine.companion.temporaryController = null;

            ModEntry.modHelper.Events.GameLoop.UpdateTicked += GameLoop_UpdateTicked;
            ModEntry.modHelper.Events.GameLoop.TimeChanged  += GameLoop_TimeChanged;
            ModEntry.modHelper.Events.GameLoop.DayEnding    += GameLoop_DayEnding;

            ModEntry.modHelper.Events.Player.Warped += Player_Warped;

            ModEntry.modHelper.Events.Display.MenuChanged += Display_MenuChanged;

            ModEntry.modHelper.Events.World.NpcListChanged += World_NpcListChanged;;
        }
Ejemplo n.º 4
0
 public FightController(AI_StateMachine ai, IModEvents events) : base(ai)
 {
     this.realLeader = ai.player;
     this.leader     = null;
     this.pathFinder.GoalCharacter = null;
     this.events = events;
 }
        public LovePeaceController(AI_StateMachine ai, IModEvents events) : base(ai)
        {
            this.lovedMonsters = new List <LovedMonster>();
            this.loveTexture   = Game1.content.Load <Texture2D>(ai.ContentLoader.GetAssetKey("~/Sprites/love.png"));
            this.bubbles       = this.ai.ContentLoader.LoadStrings("Strings/SpeechBubbles");
            this.events        = events;

            events.Player.Warped += this.Player_Warped;
        }
Ejemplo n.º 6
0
        public IdleController(AI_StateMachine ai, IContentLoader loader)
        {
            Dictionary <string, string> idleNpcDefinitions  = loader.LoadStrings("Data/IdleNPCDefinitions");
            Dictionary <string, string> behaviorDefinitions = loader.LoadStrings("Data/IdleBehaviors");

            this.ai     = ai;
            this.loader = loader;
            this.Setup(idleNpcDefinitions, behaviorDefinitions);
        }
Ejemplo n.º 7
0
        public override void Entry()
        {
            if (this.StateMachine.Companion == null)
            {
                throw new TransitionStateException("Companion NPC can't be null for recruit.");
            }

            this.ai            = new AI_StateMachine(this.StateMachine, this.StateMachine.CompanionManager.Hud, this.Events, this.monitor);
            this.timeOfRecruit = Game1.timeOfDay;

            if (this.StateMachine.Companion.doingEndOfRouteAnimation.Value)
            {
                this.FinishScheduleAnimation();
            }

            this.FixProblemsWithNPC();

            this.Events.GameLoop.UpdateTicked   += this.GameLoop_UpdateTicked;
            this.Events.GameLoop.TimeChanged    += this.GameLoop_TimeChanged;
            this.Events.Player.Warped           += this.Player_Warped;
            this.Events.Input.ButtonPressed     += this.Input_ButtonPressed;
            this.SpecialEvents.RenderedLocation += this.SpecialEvents_RenderedLocation;

            this.StateMachine.Companion.CurrentDialogue.Clear();
            this.recruitedDialogue = this.StateMachine.Dialogues.GenerateDialogue("companionRecruited");
            this.CanPerformAction  = true;

            if (this.recruitedDialogue != null)
            {
                this.StateMachine.Companion.CurrentDialogue.Push(this.recruitedDialogue);
            }

            foreach (string skill in this.StateMachine.Metadata.PersonalSkills)
            {
                string text = this.StateMachine.ContentLoader.LoadString($"Strings/Strings:skill.{skill}", this.StateMachine.Companion.displayName)
                              + Environment.NewLine
                              + this.StateMachine.ContentLoader.LoadString($"Strings/Strings:skillDescription.{skill}").Replace("#", Environment.NewLine);
                this.StateMachine.CompanionManager.Hud.AddSkill(skill, text);
            }

            this.StateMachine.CompanionManager.Hud.AssignCompanion(this.StateMachine.Companion);
            this.BuffManager.AssignBuffs();
            this.ai.Setup();

            if (this.BuffManager.HasProsthetics())
            {
                var key  = this.StateMachine.CompanionManager.Config.ChangeBuffButton;
                var desc = this.StateMachine.ContentLoader.LoadString("Strings/Strings:prosteticsChangeButton", key, this.StateMachine.Companion.displayName);
                this.StateMachine.CompanionManager.Hud.AddKey(key, desc);
            }

            if (Helper.IsSpouseMarriedToFarmer(this.StateMachine.Companion, this.StateMachine.CompanionManager.Farmer))
            {
                this.TimeToBye = 2400; // Extend adventuring time to midnight for Wife/Husband
            }
        }
Ejemplo n.º 8
0
        internal FollowController(AI_StateMachine ai)
        {
            this.pathToFollow = new Queue <Vector2>();
            this.ai           = ai;
            this.leader       = ai.player;
            this.follower     = ai.npc;
            this.pathFinder   = new PathFinder(this.follower.currentLocation, this.follower, this.leader);
            this.joystick     = new FollowJoystick(ref this.follower, this.pathFinder);

            this.ai.LocationChanged += this.Ai_LocationChanged;
            this.joystick.Move      += this.OnMove;
        }
Ejemplo n.º 9
0
        public override void Entry()
        {
            this.ai            = new AI_StateMachine(this.StateMachine, this.StateMachine.CompanionManager.Hud, this.Events, this.monitor);
            this.timeOfRecruit = Game1.timeOfDay;

            if (this.StateMachine.Companion.doingEndOfRouteAnimation.Value)
            {
                this.FinishScheduleAnimation();
            }

            this.StateMachine.Companion.faceTowardFarmerTimer = 0;
            this.StateMachine.Companion.movementPause         = 0;
            this.StateMachine.Companion.followSchedule        = false;
            this.StateMachine.Companion.Schedule            = null;
            this.StateMachine.Companion.controller          = null;
            this.StateMachine.Companion.temporaryController = null;
            this.StateMachine.Companion.eventActor          = true;
            this.StateMachine.Companion.farmerPassesThrough = true;

            this.Events.GameLoop.UpdateTicked   += this.GameLoop_UpdateTicked;
            this.Events.GameLoop.TimeChanged    += this.GameLoop_TimeChanged;
            this.Events.Player.Warped           += this.Player_Warped;
            this.Events.Input.ButtonPressed     += this.Input_ButtonPressed;
            this.SpecialEvents.RenderedLocation += this.SpecialEvents_RenderedLocation;

            this.recruitedDialogue = DialogueHelper.GenerateDialogue(this.StateMachine.Companion, "companionRecruited");
            this.CanPerformAction  = true;

            if (this.recruitedDialogue != null)
            {
                this.StateMachine.Companion.CurrentDialogue.Push(this.recruitedDialogue);
            }

            foreach (string skill in this.StateMachine.Metadata.PersonalSkills)
            {
                string text = this.StateMachine.ContentLoader.LoadString($"Strings/Strings:skill.{skill}", this.StateMachine.Companion.displayName)
                              + Environment.NewLine
                              + this.StateMachine.ContentLoader.LoadString($"Strings/Strings:skillDescription.{skill}").Replace("#", Environment.NewLine);
                this.StateMachine.CompanionManager.Hud.AddSkill(skill, text);
            }

            this.StateMachine.CompanionManager.Hud.AssignCompanion(this.StateMachine.Companion);
            this.BuffManager.AssignBuffs();
            this.ai.Setup();

            if (this.BuffManager.HasProsthetics())
            {
                var key  = this.StateMachine.CompanionManager.Config.ChangeBuffButton;
                var desc = this.StateMachine.ContentLoader.LoadString("Strings/Strings:prosteticsChangeButton", key, this.StateMachine.Companion.displayName);
                this.StateMachine.CompanionManager.Hud.AddKey(key, desc);
            }
        }
Ejemplo n.º 10
0
        public ForageController(AI_StateMachine ai, IModEvents events)
        {
            this.ai         = ai;
            this.ignoreList = new List <TerrainFeature>();
            this.pathFinder = new PathFinder(this.Forager.currentLocation, this.Forager, this.ai.player);
            this.joystick   = new NpcMovementController(this.Forager, this.pathFinder);
            this.joystick.EndOfRouteReached += this.Joystick_EndOfRouteReached;
            this.ai.LocationChanged         += this.Ai_LocationChanged;
            this.r = new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed);
            this.foragedObjects = new Stack <Item>();
            this.forages        = this.LoadForages();

            events.GameLoop.TimeChanged += this.GameLoop_TimeChanged;
        }
Ejemplo n.º 11
0
        public override void Exit()
        {
            this.BuffManager.ReleaseBuffs();
            this.ai.Dispose();

            this.StateMachine.Companion.eventActor          = false;
            this.StateMachine.Companion.farmerPassesThrough = false;
            this.CanCreateDialogue = false;

            this.Events.GameLoop.UpdateTicked -= this.GameLoop_UpdateTicked;
            this.Events.GameLoop.TimeChanged  -= this.GameLoop_TimeChanged;
            this.Events.Player.Warped         -= this.Player_Warped;

            this.ai = null;
            this.dismissalDialogue = null;
        }
Ejemplo n.º 12
0
        public override void Entry()
        {
            this.ai = new AI_StateMachine(this.StateMachine, this.StateMachine.CompanionManager.Hud, this.Events, this.monitor);

            if (this.StateMachine.Companion.doingEndOfRouteAnimation.Value)
            {
                this.FinishScheduleAnimation();
            }

            this.StateMachine.Companion.faceTowardFarmerTimer = 0;
            this.StateMachine.Companion.movementPause         = 0;
            this.StateMachine.Companion.followSchedule        = false;
            this.StateMachine.Companion.Schedule            = null;
            this.StateMachine.Companion.controller          = null;
            this.StateMachine.Companion.temporaryController = null;
            this.StateMachine.Companion.eventActor          = true;
            this.StateMachine.Companion.farmerPassesThrough = true;

            if (this.StateMachine.Companion.isMarried() && Patches.SpouseReturnHomePatch.recruitedSpouses.IndexOf(this.StateMachine.Companion.Name) < 0)
            {
                // Avoid returning recruited wife/husband to FarmHouse when is on Farm and it's after 1pm
                Patches.SpouseReturnHomePatch.recruitedSpouses.Add(this.StateMachine.Companion.Name);
            }

            this.Events.GameLoop.UpdateTicked   += this.GameLoop_UpdateTicked;
            this.Events.GameLoop.TimeChanged    += this.GameLoop_TimeChanged;
            this.Events.Player.Warped           += this.Player_Warped;
            this.SpecialEvents.RenderedLocation += this.SpecialEvents_RenderedLocation;

            if (DialogueHelper.GetVariousDialogueString(this.StateMachine.Companion, "companionRecruited", out string dialogueText))
            {
                this.StateMachine.Companion.setNewDialogue(dialogueText);
            }
            this.CanCreateDialogue = true;

            foreach (string skill in this.StateMachine.Metadata.PersonalSkills)
            {
                string text = this.StateMachine.ContentLoader.LoadString($"Strings/Strings:skill.{skill}", this.StateMachine.Companion.displayName)
                              + Environment.NewLine
                              + this.StateMachine.ContentLoader.LoadString($"Strings/Strings:skillDescription.{skill}").Replace("#", Environment.NewLine);
                this.StateMachine.CompanionManager.Hud.AddSkill(skill, text);
            }

            this.StateMachine.CompanionManager.Hud.AssignCompanion(this.StateMachine.Companion);
            this.BuffManager.AssignBuffs();
            this.ai.Setup();
        }
Ejemplo n.º 13
0
        public FollowController(AI_StateMachine ai)
        {
            this.pathToFollow = new Queue <Vector2>();
            this.ai           = ai;
            this.leader       = ai.player;
            this.follower     = ai.npc;
            this.pathFinder   = new PathFinder(this.follower.currentLocation, this.follower, this.leader);

            this.characterMoveUp    = typeof(Character).GetField("moveUp", BindingFlags.NonPublic | BindingFlags.Instance);
            this.characterMoveDown  = typeof(Character).GetField("moveDown", BindingFlags.NonPublic | BindingFlags.Instance);
            this.characterMoveLeft  = typeof(Character).GetField("moveLeft", BindingFlags.NonPublic | BindingFlags.Instance);
            this.characterMoveRight = typeof(Character).GetField("moveRight", BindingFlags.NonPublic | BindingFlags.Instance);

            this.ai.LocationChanged += this.Ai_LocationChanged;

            this.gatesInThisLocation = this.CheckForGatesInThisLocation();
        }
Ejemplo n.º 14
0
        public FightController(AI_StateMachine ai, IContentLoader content, IModEvents events, int sword) : base(ai)
        {
            this.attackRadius             = 1.25f * Game1.tileSize;
            this.backupRadius             = 0.9f * Game1.tileSize;
            this.realLeader               = ai.player;
            this.leader                   = null;
            this.pathFinder.GoalCharacter = null;
            this.events                   = events;
            this.weapon                   = this.GetSword(sword);
            this.bubbles                  = content.LoadStrings("Strings/SpeechBubbles");
            this.fightSpeechTriggerThres  = ai.Csm.HasSkill("warrior") ? 0.25 : 0.7;

            if (Compat.IsModLoaded(ModUids.PACIFISTMOD_UID))
            {
                this.kissFrames = this.ai.ContentLoader.LoadData <string, string>("Data/FightFrames");
            }

            this.attackAnimation = new List <FarmerSprite.AnimationFrame>[4]
            {
                // Up
                new List <FarmerSprite.AnimationFrame>()
                {
                    new FarmerSprite.AnimationFrame(8, 100),
                    new FarmerSprite.AnimationFrame(9, 250),
                },
                // Right
                new List <FarmerSprite.AnimationFrame>()
                {
                    new FarmerSprite.AnimationFrame(6, 100),
                    new FarmerSprite.AnimationFrame(7, 250),
                },
                // Down
                new List <FarmerSprite.AnimationFrame>()
                {
                    new FarmerSprite.AnimationFrame(0, 100),
                    new FarmerSprite.AnimationFrame(1, 250),
                },
                // Left
                new List <FarmerSprite.AnimationFrame>()
                {
                    new FarmerSprite.AnimationFrame(14, 100),
                    new FarmerSprite.AnimationFrame(15, 250),
                },
            };
        }
Ejemplo n.º 15
0
        public override void Exit()
        {
            this.BuffManager.ReleaseBuffs();
            this.ai.Dispose();

            this.StateMachine.Companion.eventActor          = false;
            this.StateMachine.Companion.farmerPassesThrough = false;
            this.CanPerformAction = false;

            this.SpecialEvents.RenderedLocation -= this.SpecialEvents_RenderedLocation;
            this.Events.Input.ButtonPressed     -= this.Input_ButtonPressed;
            this.Events.GameLoop.UpdateTicked   -= this.GameLoop_UpdateTicked;
            this.Events.GameLoop.TimeChanged    -= this.GameLoop_TimeChanged;
            this.Events.Player.Warped           -= this.Player_Warped;

            this.ai = null;
            this.dismissalDialogue = null;
            this.StateMachine.CompanionManager.Hud.Reset();
        }
Ejemplo n.º 16
0
        public FishController(AI_StateMachine ai, IModEvents events)
        {
            this.ai          = ai;
            this.fisher      = ai.npc;
            this.farmer      = ai.farmer;
            this.fishingSpot = this.negativeOne;
            this.pathFinder  = new PathFinder(this.fisher.currentLocation, this.fisher, this.farmer);
            this.joystick    = new NpcMovementController(this.fisher, this.pathFinder);
            this.fishCaught  = new Stack <SObject>();

            if (!ai.Csm.HasSkill("fisherman"))
            {
                return;
            }

            ai.LocationChanged              += this.Ai_LocationChanged;
            events.GameLoop.TimeChanged     += this.OnTimeChanged;
            this.joystick.EndOfRouteReached += this.ArrivedFishingSpot;

            string key = $"{ai.npc.Name.ToLower()}_sideFish";
            var    animationDescriptions = this.ai.ContentLoader.LoadData <string, string>("Data/AnimationDescriptions");

            if (!animationDescriptions.ContainsKey(key))
            {
                ai.Monitor.Log($"No fishing animation for `{ai.npc.Name}`: Key `{key}` doesn't exist.", LogLevel.Error);
                return;
            }

            string[] animation = animationDescriptions[key].Split('/');

            if (animation.Length < 3)
            {
                ai.Monitor.Log($"Wrong animation description format for key `{key}`", LogLevel.Error);
                return;
            }

            int[] frames = Utility.parseStringToIntArray(animation[1]);

            this.fishingLeftAnim  = frames.Select(f => new FarmerSprite.AnimationFrame(f, 4000, false, true, null, false)).ToList();
            this.fishingRightAnim = frames.Select(f => new FarmerSprite.AnimationFrame(f, 4000)).ToList();
        }
Ejemplo n.º 17
0
        public FightController(AI_StateMachine ai, IContentLoader content, IModEvents events, int sword) : base(ai)
        {
            this.attackRadius             = 1.25f * Game1.tileSize;
            this.backupRadius             = 0.9f * Game1.tileSize;
            this.realLeader               = ai.player;
            this.leader                   = null;
            this.pathFinder.GoalCharacter = null;
            this.events                   = events;
            this.weapon                   = this.GetSword(sword, this.ai.metadata.Profession == "warrior");
            this.bubbles                  = content.LoadStrings("Strings/SpeechBubbles");
            this.fightSpeechTriggerThres  = ai.metadata.Profession == "warrior" ? 0.33 : 0.15;

            this.attackAnimation = new List <FarmerSprite.AnimationFrame>[4]
            {
                // Up
                new List <FarmerSprite.AnimationFrame>()
                {
                    new FarmerSprite.AnimationFrame(8, 100),
                    new FarmerSprite.AnimationFrame(9, 250),
                },
                // Right
                new List <FarmerSprite.AnimationFrame>()
                {
                    new FarmerSprite.AnimationFrame(6, 100),
                    new FarmerSprite.AnimationFrame(7, 250),
                },
                // Down
                new List <FarmerSprite.AnimationFrame>()
                {
                    new FarmerSprite.AnimationFrame(0, 100),
                    new FarmerSprite.AnimationFrame(1, 250),
                },
                // Left
                new List <FarmerSprite.AnimationFrame>()
                {
                    new FarmerSprite.AnimationFrame(14, 100),
                    new FarmerSprite.AnimationFrame(15, 250),
                },
            };
        }
Ejemplo n.º 18
0
        public override void Exit()
        {
            this.BuffManager.ReleaseBuffs();
            this.ai.Dispose();

            if (Patches.SpouseReturnHomePatch.recruitedSpouses.IndexOf(this.StateMachine.Companion.Name) >= 0)
            {
                // Allow dissmised wife/husband to return to FarmHouse when is on Farm
                Patches.SpouseReturnHomePatch.recruitedSpouses.Remove(this.StateMachine.Companion.Name);
            }

            this.StateMachine.Companion.eventActor          = false;
            this.StateMachine.Companion.farmerPassesThrough = false;
            this.CanCreateDialogue = false;

            this.SpecialEvents.RenderedLocation -= this.SpecialEvents_RenderedLocation;
            this.Events.GameLoop.UpdateTicked   -= this.GameLoop_UpdateTicked;
            this.Events.GameLoop.TimeChanged    -= this.GameLoop_TimeChanged;
            this.Events.Player.Warped           -= this.Player_Warped;

            this.ai = null;
            this.dismissalDialogue = null;
            this.StateMachine.CompanionManager.Hud.Reset();
        }
Ejemplo n.º 19
0
 // Start is called before the first frame update
 void Start()
 {
     machine = GetComponent <AI_StateMachine>();
 }
Ejemplo n.º 20
0
    // The Update() method is being called every frame. Have fun!
    public void Update()
    {
        DateTime              currentTime = DateTime.UtcNow;
        Network_Player        player      = RAPI.getLocalPlayer();
        Network_Host_Entities nhe         = ComponentManager <Network_Host_Entities> .Value;
        Raft       raft = ComponentManager <Raft> .Value;
        Rigidbody  body = Traverse.Create(raft).Field("body").GetValue() as Rigidbody;
        RewardData reward;

        if (rewardsQueue.TryDequeue(out reward))
        {
            switch (reward.action)
            {
            case "sound":
                system.playSound(sounds[reward.args[0]], channels, false, out newChannel);
                break;

            case "message":
                chat.SendChatMessage(string.Join(" ", reward.args), SteamUser.GetSteamID());
                break;

            case "item":
                Item_Base item   = ItemManager.GetItemByName(reward.args[0]);
                int       amount = 1;
                int.TryParse(reward.args[1], out amount);
                Helper.DropItem(new ItemInstance(item, amount, item.MaxUses), player.transform.position, player.CameraTransform.forward, player.transform.ParentedToRaft());
                break;

            case "inventory_bomb":
                chat.SendChatMessage("Inventory Bomb!", SteamUser.GetSteamID());
                foreach (Slot s in player.Inventory.allSlots)
                {
                    player.Inventory.DropItem(s);
                }
                foreach (Slot s in player.Inventory.equipSlots)
                {
                    player.Inventory.DropItem(s);
                }
                break;

            case "stat_edit":
                //TODO
                //player.PersonController.gravity = 20;
                //player.PersonController.swimSpeed = 2;
                //player.PersonController.normalSpeed = 3;
                //player.PersonController.jumpSpeed = 8;
                //player.Stats.stat_thirst.Value -= 5;
                string action       = reward.args[0];
                string stat         = reward.args[1];
                float  changeAmount = 1;
                float.TryParse(reward.args[2], out changeAmount);
                int duration = 1;
                int.TryParse(reward.args[3], out duration);

                bool contained = false;
                foreach (StatData data in statsEdited)
                {
                    if (data.stat.Equals(stat))
                    {
                        data.duration += duration;
                        contained      = true;
                    }
                }

                if (!contained)
                {
                    StatData data = getStatData(player, stat, action, changeAmount);
                    data.duration    = duration * 1000;
                    data.timeStarted = DateTime.UtcNow;
                    setStatVal(player, stat, data.currentValue);
                    if (duration != -1)
                    {
                        statsEdited.Add(data);
                    }
                }

                break;

            case "move":
                push     = true;
                pushData = new PushData(new Vector3(-4, 0, -4.3f), currentTime, 250);
                break;

            case "spawn_entity":
                Vector3 pos   = player.FeetPosition;
                float   scale = 1;
                if (reward.args.Length > 1)
                {
                    float.TryParse(reward.args[1], out scale);
                }
                int amountFromEntries = 1;
                if (reward.args.Length > 2)
                {
                    int.TryParse(reward.args[2], out amountFromEntries);
                }
                int spawnDuration = 1;
                if (reward.args.Length > 3)
                {
                    int.TryParse(reward.args[3], out spawnDuration);
                }
                TempEntity tempEnt;
                uint       objIndex = SaveAndLoad.GetUniqueObjectIndex();
                for (int index = 0; index < amountFromEntries; ++index)
                {
                    switch (reward.args[0])
                    {
                    case "stone_bird":
                        tempEnt = new TempEntity(nhe.CreateAINetworkBehaviour(AI_NetworkBehaviourType.StoneBird, pos, scale, objIndex, SaveAndLoad.GetUniqueObjectIndex(), null));
                        break;

                    case "puffer_fish":
                        tempEnt = new TempEntity(nhe.CreateAINetworkBehaviour(AI_NetworkBehaviourType.PufferFish, pos, scale, objIndex, SaveAndLoad.GetUniqueObjectIndex(), null));
                        break;

                    case "llama":
                        tempEnt = new TempEntity(nhe.CreateAINetworkBehaviour(AI_NetworkBehaviourType.Llama, pos, scale, objIndex, SaveAndLoad.GetUniqueObjectIndex(), null));
                        (tempEnt.ent as AI_NetworkBehaviour_Domestic).QuickTameLate();
                        break;

                    case "goat":
                        tempEnt = new TempEntity(nhe.CreateAINetworkBehaviour(AI_NetworkBehaviourType.Goat, pos, scale, objIndex, SaveAndLoad.GetUniqueObjectIndex(), null));
                        (tempEnt.ent as AI_NetworkBehaviour_Domestic).QuickTameLate();
                        break;

                    case "chicken":
                        tempEnt = new TempEntity(nhe.CreateAINetworkBehaviour(AI_NetworkBehaviourType.Chicken, pos, scale, objIndex, SaveAndLoad.GetUniqueObjectIndex(), null));
                        (tempEnt.ent as AI_NetworkBehaviour_Domestic).QuickTameLate();
                        break;

                    case "boar":
                        tempEnt = new TempEntity(nhe.CreateAINetworkBehaviour(AI_NetworkBehaviourType.Boar, pos, scale, objIndex, SaveAndLoad.GetUniqueObjectIndex(), null));
                        break;

                    case "rat":
                        tempEnt = new TempEntity(nhe.CreateAINetworkBehaviour(AI_NetworkBehaviourType.Rat, pos, scale, objIndex, SaveAndLoad.GetUniqueObjectIndex(), null));
                        break;

                    case "shark":
                        tempEnt = new TempEntity(nhe.CreateAINetworkBehaviour(AI_NetworkBehaviourType.Shark, pos, scale, objIndex, SaveAndLoad.GetUniqueObjectIndex(), null));
                        break;

                    case "bear":
                        tempEnt = new TempEntity(nhe.CreateAINetworkBehaviour(AI_NetworkBehaviourType.Bear, pos, scale, objIndex, SaveAndLoad.GetUniqueObjectIndex(), null));
                        break;

                    case "mama_bear":
                        tempEnt = new TempEntity(nhe.CreateAINetworkBehaviour(AI_NetworkBehaviourType.MamaBear, pos, scale, objIndex, SaveAndLoad.GetUniqueObjectIndex(), null));
                        break;

                    case "seagull":
                        //TODO: It's not like the others for some reason.....
                        tempEnt = null;
                        break;

                    default:
                        tempEnt = null;
                        break;
                    }
                    if (tempEnt != null && spawnDuration != -1)
                    {
                        Semih_Network network = ComponentManager <Semih_Network> .Value;
                        Message_CreateAINetworkBehaviour networkBehaviour2 = new Message_CreateAINetworkBehaviour(Messages.CreateAINetworkBehaviour, network.NetworkIDManager, objIndex, pos, tempEnt.ent, null);
                        if (network == null)
                        {
                            network = ComponentManager <Semih_Network> .Value;
                        }
                        network.RPC(networkBehaviour2, Target.Other, EP2PSend.k_EP2PSendReliable, NetworkChannel.Channel_Game);
                        tempEnt.spawned  = DateTime.UtcNow;
                        tempEnt.duration = spawnDuration * 1000;
                        tempEntities.Add(tempEnt);
                    }
                }
                break;

            case "set_weather":
                string weatherName = reward.args[0];
                bool   instant;
                bool.TryParse(reward.args[1], out instant);
                WeatherManager wm      = ComponentManager <WeatherManager> .Value;
                Randomizer     weather = Traverse.Create(ComponentManager <WeatherManager> .Value).Field("weatherConnections").GetValue() as Randomizer;
                Weather        w       = null;
                foreach (Weather we in weather.GetAllItems <Weather>())
                {
                    if (we.name.Equals(weatherName))
                    {
                        w = we;
                    }
                }

                if (w != null)
                {
                    wm.StopAllCoroutines();
                    wm.StartCoroutine(wm.StartNewWeather(w, instant));
                }
                break;

            case "set_time":
                AzureSkyController skyController = ComponentManager <AzureSkyController> .Value;
                int hours = 1;
                int.TryParse(reward.args[0], out hours);
                int minutes = 1;
                int.TryParse(reward.args[1], out minutes);
                skyController.timeOfDay.GotoTime(hours, minutes);
                break;

            case "pickup_trash":
                WaterFloatSemih2[] floatingObjects = FindObjectsOfType <WaterFloatSemih2>();
                float radius = 100;
                float.TryParse(reward.args[0], out radius);
                foreach (WaterFloatSemih2 trash in floatingObjects)
                {
                    try
                    {
                        if (!trash.GetComponent <PickupItem>().isDropped&& Vector3.Distance(trash.transform.position, player.FeetPosition) < radius)
                        {
                            PickupItem_Networked pickup = trash.GetComponentInParent <PickupItem_Networked>();
                            PickupObjectManager.RemovePickupItemNetwork(pickup, SteamUser.GetSteamID());
                        }
                    }
                    catch
                    {
                    }
                }
                break;

            case "command":
                RConsole console = Traverse.Create(typeof(RConsole)).Field("ConsoleInstance").GetValue() as RConsole;
                console.sendCommand(string.Join(" ", reward.args));
                break;

            case "meteor_shower":
                int meteorsToSpawn = 1;
                if (reward.args.Length > 0)
                {
                    int.TryParse(reward.args[0], out meteorsToSpawn);
                }
                int spawnRadius = 1;
                if (reward.args.Length > 1)
                {
                    int.TryParse(reward.args[1], out spawnRadius);
                }
                int meteorDamage = 1;
                if (reward.args.Length > 2)
                {
                    int.TryParse(reward.args[2], out meteorDamage);
                }

                if (stoneDropPrefab == null)
                {
                    AI_NetworkBehaviour_StoneBird ainbsb = (AI_NetworkBehaviour_StoneBird)nhe.CreateAINetworkBehaviour(AI_NetworkBehaviourType.StoneBird, player.FeetPosition, 0, SaveAndLoad.GetUniqueObjectIndex(), SaveAndLoad.GetUniqueObjectIndex(), null);
                    stoneDropPrefab = Traverse.Create(ainbsb.stateMachineStoneBird.dropStoneState).Field("stoneDropPrefab").GetValue() as StoneDrop;
                    ainbsb.Kill();
                }

                for (int i = 0; i < meteorsToSpawn; i++)
                {
                    Vector3 dropPosition = player.FeetPosition + new Vector3(UnityEngine.Random.Range(-spawnRadius, spawnRadius), 200, UnityEngine.Random.Range(-spawnRadius, spawnRadius));
                    meteors.Add(new Meteor(dropPosition, meteorDamage));
                }
                break;

            case "push_raft":
                float pushForce;
                float.TryParse(reward.args[0], out pushForce);
                body.AddForce(getBoundedRandVector(0.5f, 1) * pushForce, ForceMode.Impulse);
                break;

            case "rotate_raft":
                float rotationForce;
                float.TryParse(reward.args[0], out rotationForce);
                body.AddTorque(new Vector3(0, rotationForce, 0), ForceMode.Impulse);
                break;
            }
        }


        for (int i = statsEdited.Count - 1; i >= 0; i--)
        {
            StatData data = statsEdited[i];
            if ((currentTime - data.timeStarted).TotalMilliseconds > data.duration)
            {
                setStatVal(player, data.stat, data.originalValue);
                statsEdited.RemoveAt(i);
                chat.SendChatMessage(data.stat + " back to normal!", SteamUser.GetSteamID());
            }
        }

        for (int i = tempEntities.Count - 1; i >= 0; i--)
        {
            TempEntity ent = tempEntities[i];
            if ((currentTime - ent.spawned).TotalMilliseconds > ent.duration)
            {
                if (ent.ent != null)
                {
                    Network_Entity entity = ent.ent.networkEntity;
                    entity.Button_Kill();
                    AI_StateMachine stateMachine = ent.ent.GetComponent <AI_StateMachine>();
                    if (stateMachine is AI_StateMachine_Animal)
                    {
                        Traverse.Create((stateMachine as AI_StateMachine_Animal).deadState).Method("RemoveBody").GetValue();
                    }
                }
                tempEntities.RemoveAt(i);
            }
        }

        if (meteors.Count > 0)
        {
            meteorDelay--;
            if (meteorDelay <= 0)
            {
                meteorDelay = meteorDelayTot;
                StoneDrop stone = Instantiate(stoneDropPrefab, meteors.ElementAt(0).pos, Quaternion.identity);
                float     scale = UnityEngine.Random.Range(0.5f, 4f);
                stone.rigidBody.transform.localScale = new Vector3(scale, scale, scale);
                stone.rigidBody.AddForce(Vector3.down * meteors.ElementAt(0).damage, ForceMode.Impulse);
                meteors.RemoveAt(0);
            }
        }

        if (Input.GetKeyDown(KeyCode.Keypad1))
        {
            //Item_Base item = ItemManager.GetItemByName("Watermelon");
            //Helper.DropItem(new ItemInstance(item, 10, item.MaxUses), player.transform.position, player.CameraTransform.forward, player.transform.ParentedToRaft());
        }
        else if (Input.GetKeyDown(KeyCode.Keypad2))
        {
        }

        if (push)
        {
            player.PersonController.controller.SimpleMove(pushData.push);
            if ((currentTime - pushData.startTime).TotalMilliseconds > pushData.duration)
            {
                pushData.left--;
                if (pushData.left == 0)
                {
                    push = false;
                }
                else
                {
                    pushData.startTime = currentTime;
                    pushData.push      = getBoundedRandVector(3, 5);
                }
            }
        }
    }