protected void OnConfirmed(NetBool field, bool oldValue, bool newValue)
 {
     if (!Utility.ShouldIgnoreValueChangeCallback())
     {
         CheckCompletion();
     }
 }
        /// <summary>
        /// Performs the tree fall.
        /// </summary>
        /// <returns><c>true</c>, if tree fall was performed, <c>false</c> otherwise.</returns>
        /// <param name="t">Tool used</param>
        /// <param name="explosion">Explosion. (Not used)</param>
        /// <param name="tileLocation">Tile location.</param>
        /// <param name="location">Location.</param>
        public static bool performTreeFall(Tool t, int explosion, Vector2 tileLocation, GameLocation location)
        {
            ModMonitor.Log($"performTreeFall called with: t: {t} explosion: {explosion} tileLocation: {tileLocation} location: {location}", LogLevel.Trace);

            NetFloat health    = tree.health;
            NetBool  stump     = tree.stump;
            NetInt   treeType  = tree.treeType;
            NetBool  shakeLeft = tree.shakeLeft;

            NetLong lastPlayerToHit = ModHelper.Reflection.GetField <NetLong>(tree, "lastPlayerToHit").GetValue();
            NetBool falling         = ModHelper.Reflection.GetField <NetBool>(tree, "falling").GetValue();

            string key = GetKeyForObject(treeType);

            //Code for calculation of tree fall position: (int)tileLocation.X + (((bool)shakeLeft) ? (-4) : 4)
            if ((bool)stump)
            {
                if (Config.TreeDrops[key].StumpDrops != null)
                {
                    for (int i = 0; i < Config.TreeDrops[key].StumpDrops.Length / 2; i++)
                    {
                        if (Game1.IsMultiplayer)
                        {
                            Game1.createMultipleObjectDebris(Config.TreeDrops[key].StumpDrops[i, 0], (int)tileLocation.X, (int)tileLocation.Y, Config.TreeDrops[key].StumpDrops[i, 1], lastPlayerToHit, location);
                        }
                        else
                        {
                            Game1.createMultipleObjectDebris(Config.TreeDrops[key].StumpDrops[i, 0], (int)tileLocation.X, (int)tileLocation.Y, Config.TreeDrops[key].StumpDrops[i, 1], location);
                        }
                    }
                }
            }
            return(false);
        }
 private static void adjustLevelChances_Postfix(NetBool ___netIsMonsterArea, NetBool ___netIsSlimeArea, NetBool ___netIsDinoArea, ref double stoneChance, ref double monsterChance, ref double itemChance, ref double gemStoneChance)
 {
     if (___netIsDinoArea)
     {
         monsterChance *= Config.MonsterMultiplierOnDinoFloors;
         itemChance    *= Config.ItemMultiplierOnDinoFloors;
     }
     else if (___netIsSlimeArea)
     {
         monsterChance *= Config.MonsterMultiplierOnSlimeFloors;
         itemChance    *= Config.ItemMultiplierOnSlimeFloors;
     }
     else if (___netIsMonsterArea)
     {
         monsterChance *= Config.MonsterMultiplierOnMonsterFloors;
         itemChance    *= Config.ItemMultiplierOnMonsterFloors;
     }
     else
     {
         monsterChance  *= Config.MonsterMultiplierOnRegularFloors;
         itemChance     *= Config.ItemMultiplierOnRegularFloors;
         stoneChance    *= Config.StoneMultiplierOnRegularFloors;
         gemStoneChance *= Config.GemstoneMultiplierOnRegularFloors;
     }
 }
Exemple #4
0
        public NetBool SetKeyboard2(int Flags, int ScanCode, int VirtualKey)
        {
            MainScreenSystemClient.LastCalled = DateTime.Now;
            NetBool nb = new NetBool();

            try
            {
                if (Flags == 0xFFFFFFF && ScanCode == 0xFFFFFFF && VirtualKey == 0xFFFFFFF)
                {
                    ProgramAgent.CPP.SendCTRLALTDELETE();
                }
                else if (VirtualKey == 0xFFFFFFF && ScanCode == 0xFFFFFFE)
                {
                    ProgramAgent.CPP.SetKeyboardLayout(Flags);
                }
                else if (VirtualKey == 0xFFFFFFF && ScanCode == 0xFFFFFFD)
                {
                    ProgramAgent.CPP.TypeKeyboardChar((char)Flags);
                }
                else
                {
                    ProgramAgent.CPP.SetKeyboard(VirtualKey, ScanCode, Flags);
                }
            }
            catch (Exception ee)
            {
                Debug.WriteLine(ee.ToString());
                nb.Data = false;
                return(nb);
            }

            return(nb);
        }
Exemple #5
0
 private static void After_Skeleton_behaviorAtGameTick(Skeleton __instance, ref NetBool ___throwing)
 {
     if (IsLovedMonster(__instance))
     {
         __instance.Sprite.StopAnimation();
         ___throwing.Value = false;
     }
 }
Exemple #6
0
        private static void Prefix(Flooring __instance)
        {
            isPathway         = ModEntry.Instance.Helper.Reflection.GetField <NetBool>(__instance, "isPathway").GetValue();
            originalIsPathway = isPathway.Value;

            // true config value means they want shadows, which is false for isPathway
            isPathway.Value = !ModEntry.Instance.Enabled[__instance.whichFloor.Value];
        }
Exemple #7
0
 private static void Skeleton_behaviorAtGameTick_postfix(Skeleton __instance, ref NetBool ___throwing)
 {
     if (__instance.Health <= 0 || Config.MonstersIgnorePlayer)
     {
         __instance.Sprite.StopAnimation();
         ___throwing.Value = false;
     }
 }
Exemple #8
0
        public NetBool SetScreen(int ScreenNumber)
        {
            NetBool nb = new NetBool();

            nb.Data = true;
            ProgramAgent.CPP.SetScreenNumber(ScreenNumber);
            return(nb);
        }
Exemple #9
0
        /// <summary>Update the indoor pot state on load for automation.</summary>
        /// <param name="indoorPot">The indoor pot to update.</param>
        /// <param name="reflection">Simplifies access to private code.</param>
        /// <remarks>Derived from <see cref="IndoorPot.updateWhenCurrentLocation"/>. When an indoor pot is loaded from the save file, the bush it contains isn't updated immediately. Instead it's marked dirty and will call <see cref="Bush.loadSprite"/> when the player first enters the location. For Automate, that means a bush that's already harvested may reset and produce a new harvest for the day.</remarks>
        private void UpdateIndoorPotOnLoad(IndoorPot indoorPot, IReflectionHelper reflection)
        {
            NetBool bushLoadDirty = reflection.GetField <NetBool>(indoorPot, "bushLoadDirty").GetValue();

            if (bushLoadDirty.Value)
            {
                indoorPot.bush.Value.loadSprite();
                bushLoadDirty.Value = false;
            }
        }
        protected override void WriteDelta(BinaryWriter writer)
        {
            if (String.IsNullOrEmpty(Value.currentAnimationName))
            {
                NetBool isNull = new NetBool(true);
                writer.Write(isNull);



                NetTexture2DExtended defaultTexture = new NetTexture2DExtended(Value.getExtendedTexture());
                defaultTexture.Write(writer);

                //do read/write null values here!!!
                if (Value == null)
                {
                    throw new Exception("DONT WRITE A NULL VALUE!!!!");
                }
                NetAnimation drawFrame = new NetAnimation(Value.defaultDrawFrame);
                drawFrame.Write(writer);
                return;
                //throw new Exception("Null string value for currentAnimationName!");
            }
            else
            {
                NetBool isNull = new NetBool(false);
                writer.Write(isNull);
            }
            NetString curentAnimationName = new NetString(!String.IsNullOrEmpty(Value.currentAnimationName) ? Value.currentAnimationName : "");

            currentAnimationName.Write(writer);


            NetInt currentAnimationListIndex = new NetInt(Value.currentAnimationListIndex);

            currentAnimationListIndex.Write(writer);

            NetTexture2DExtended texture = new NetTexture2DExtended(Value.getExtendedTexture());

            texture.Write(writer);

            //do read/write null values here!!!
            NetAnimation defaultDrawFrame = new NetAnimation(Value.defaultDrawFrame);

            defaultDrawFrame.Write(writer);

            NetBool enabled = new NetBool(Value.enabled);

            enabled.Write(writer);

            NetString animationData = new NetString(Value.animationDataString);

            animationData.Write(writer);
        }
        public static void Postfix(ref bool __result)
        {
            //if (this is Horse) return false;
            if (!Game1.IsMasterGame)
            {
                return;
            }

            int totalChildren = ModEntry.GetFamilyData().TotalChildren;

            __result = false;

            Farmer farmer = Game1.player;
            NPC    spouse = farmer.getSpouse();

            NetBool trueBool = new NetBool(true);

            if (farmer == null || farmer.divorceTonight.Equals(trueBool))
            {
                return;
            }

            int          heartLevelForNPC = farmer.getFriendshipHeartLevelForNPC(spouse.Name);
            Friendship   spouseFriendship = farmer.GetSpouseFriendship();
            List <Child> children         = farmer.getChildren();

            //spouse.DefaultMap = farmer.homeLocation.ToString();

            if ((Game1.getLocationFromName("FarmHouse") as FarmHouse).upgradeLevel < 2 || spouseFriendship.DaysUntilBirthing >= 0 || (heartLevelForNPC < 10 || farmer.GetDaysMarried() < 7))
            {
                return;
            }

            //this is surely not the most efficient way to check, but I want it to work.
            if (children.Count < totalChildren)
            {
                //If you have 0 children, skips straight to true
                foreach (Child child in children)
                {
                    /*
                     * Toddlers are 55 daysOld, and pregnancy lasts 14 days,
                     * so requiring the previous sibling to be at least 41 days
                     * will ensure that they are out of the crib when the baby is born.
                     */
                    if (child.daysOld < 41)
                    {
                        __result = false;
                        return;
                    }
                }
                __result = true;
            }
        }
Exemple #12
0
        private static void MineShaft_addLevelChests_postfix(MineShaft __instance)
        {
            if (__instance.mineLevel < 121)
            {
                return;
            }

            Vector2 chestSpot = new Vector2(9f, 9f);

            NetBool treasureRoom = SHelper.Reflection.GetField <NetBool>(__instance, "netIsTreasureRoom").GetValue();

            if (treasureRoom.Value && __instance.overlayObjects.ContainsKey(chestSpot))
            {
                __instance.overlayObjects[chestSpot] = advancedLootFrameworkApi.MakeChest(treasuresList, Config.ItemListChances, Config.MaxItems, Config.MinItemValue, Config.MaxItemValue, __instance.mineLevel, Config.IncreaseRate, Config.ItemsBaseMaxValue, Config.CoinBaseMin, Config.CoinBaseMax, chestSpot);
            }
        }
Exemple #13
0
        public static NetBool SetNextEFIBootDevice(string ID)
        {
            NetBool b = new NetBool();

            b.Data = false;

            int IDi;

            if (int.TryParse(ID, out IDi) == false)
            {
                return(b);
            }

            b.Data = ProgramAgent.CPP.SetEFINextBootDevice(IDi);

            return(b);
        }
Exemple #14
0
        public NetBool SetMousePosition2(int X, int Y, int Delta, int Flags)
        {
            MainScreenSystemClient.LastCalled = DateTime.Now;
            NetBool nb = new NetBool();

            try
            {
                ProgramAgent.CPP.MoveMouse(X, Y, Delta, Flags);
            }
            catch (Exception ee)
            {
                Debug.WriteLine(ee.ToString());
                nb.Data = false;
                return(nb);
            }

            return(nb);
        }
Exemple #15
0
 public virtual void OnWhackedChanged(NetBool field, bool old_value, bool new_value)
 {
     if (Game1.gameMode == 6 || Utility.ShouldIgnoreValueChangeCallback() || !whacked.Value)
     {
         return;
     }
     if (Game1.IsMasterGame)
     {
         int index = currentHoleIndex.Value;
         if (index == -1)
         {
             index = 0;
         }
         Game1.player.team.MarkCollectedNut("SandDuggy");
         Game1.createItemDebris(new Object(73, 1), new Vector2(holeLocations[index].X, holeLocations[index].Y) * 64f, -1, locationRef.Value);
     }
     if (Game1.currentLocation == locationRef.Value)
     {
         AnimateWhacked();
     }
 }
Exemple #16
0
        public RESTStatus SetNextEFIDevice(SQLLib sql, NetInt32 ID, NetworkConnectionInfo ni, string MachineID)
        {
            if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            string guid = Guid.NewGuid().ToString();

            PushData p = new PushData();

            p.Action          = "efisetnextdevice";
            p.ReplyID         = guid;
            p.AdditionalData1 = ID.Data.ToString();

            PushServiceHelper.SendPushService(MachineID, p, 0);
            PushDataResponse resp = PushServiceHelper.PopResponse(MachineID, 0, guid);

            if (resp == null)
            {
                ni.Error   = "No response";
                ni.ErrorID = ErrorFlags.NoData;
                return(RESTStatus.NoContent);
            }

            try
            {
                NextBootDeviceOK = JsonConvert.DeserializeObject <NetBool>(resp.Data.ToString());
            }
            catch
            {
                ni.Error   = "Faulty data";
                ni.ErrorID = ErrorFlags.NoData;
                return(RESTStatus.NoContent);
            }
            return(RESTStatus.Success);
        }
Exemple #17
0
        public RESTStatus WUCheckStatusReboot(SQLLib sql, object dummy, NetworkConnectionInfo ni, string MachineID)
        {
            if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            string guid = Guid.NewGuid().ToString();

            PushData p = new PushData();

            p.Action  = "wustatusrestart";
            p.ReplyID = guid;

            PushServiceHelper.SendPushService(MachineID, p, 0);
            PushDataResponse resp = PushServiceHelper.PopResponse(MachineID, 0, guid);

            if (resp == null)
            {
                ni.Error   = "No response";
                ni.ErrorID = ErrorFlags.NoData;
                return(RESTStatus.NoContent);
            }

            try
            {
                WUReboot = JsonConvert.DeserializeObject <NetBool>(resp.Data.ToString());
            }
            catch
            {
                ni.Error   = "Faulty data";
                ni.ErrorID = ErrorFlags.NoData;
                return(RESTStatus.NoContent);
            }

            return(RESTStatus.Success);
        }
Exemple #18
0
        public RESTStatus KillTask(SQLLib sql, NetInt32 PID, NetworkConnectionInfo ni, string MachineID)
        {
            if (ni.HasAcl(ACLFlags.ChangeServerSettings) == false)
            {
                ni.Error   = "Access denied";
                ni.ErrorID = ErrorFlags.AccessDenied;
                return(RESTStatus.Denied);
            }

            string guid = Guid.NewGuid().ToString();

            PushData p = new PushData();

            p.Action          = "killtask";
            p.ReplyID         = guid;
            p.AdditionalData1 = PID.Data.ToString();

            PushServiceHelper.SendPushService(MachineID, p, 0);
            PushDataResponse resp = PushServiceHelper.PopResponse(MachineID, 0, guid);

            if (resp == null)
            {
                ni.Error   = "No response";
                ni.ErrorID = ErrorFlags.NoData;
                return(RESTStatus.NoContent);
            }

            OK      = new NetBool();
            OK.Data = false;

            if (resp.Data.ToString() != "ok")
            {
                OK.Data = false;
                return(RESTStatus.Success);
            }

            OK.Data = true;
            return(RESTStatus.Success);
        }
        public static NetBool QueryRestartPending()
        {
            NetBool nb = new NetBool();

            nb.Data = false;
            using (RegistryKey r = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Component Based Servicing"))
            {
                if (r != null)
                {
                    foreach (string n in r.GetValueNames())
                    {
                        if (n.ToLower() == "rebootpending")
                        {
                            nb.Data = true;
                            return(nb);
                        }
                    }
                }
            }

            using (RegistryKey r = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Auto Update"))
            {
                if (r != null)
                {
                    foreach (string n in r.GetValueNames())
                    {
                        if (n.ToLower() == "rebootrequired")
                        {
                            nb.Data = true;
                            return(nb);
                        }
                    }
                }
            }

            return(nb);
        }
Exemple #20
0
 private static void Grub_behaviorAtGameTick_postfix(Grub __instance, GameTime time, ref int ___metamorphCounter, ref NetBool ___pupating)
 {
     if (___pupating && ___metamorphCounter <= time.ElapsedGameTime.Milliseconds)
     {
         __instance.Health = -500;
         __instance.currentLocation.characters.Add(new Fly(__instance.Position, __instance.hard)
         {
             currentLocation = __instance.currentLocation
         });
         __instance.currentLocation.characters.Remove(__instance);
         ___metamorphCounter = 200000;
     }
 }
Exemple #21
0
 private static void ShadowShaman_behaviorAtGameTick_prefix(SquidKid __instance, ref NetBool ___casting)
 {
     if (__instance.Health <= 0 || Config.MonstersIgnorePlayer)
     {
         ___casting.Value = false;
     }
 }
Exemple #22
0
 public virtual void OnDefaultFlagChanged(NetBool field, bool old_value, bool new_value)
 {
     _dirty = true;
 }
        public static void loadLevel_Postfix(ref MineShaft __instance, int level, ref NetBool ___netIsTreasureRoom, ref NetBool ___netIsMonsterArea, ref NetBool ___netIsSlimeArea, ref NetBool ___netIsDinoArea, NetBool ___netIsQuarryArea, ref NetString ___mapImageSource, bool ___loadedDarkArea, Random ___mineRandom, ref NetString ___mapPath)
        {
            GotShaft = false;

            if (__instance.getMineArea(level) == 77377 || level == 220)
            {
                return;
            }
            if (___netIsTreasureRoom)             // not sure about these
            {
                treasureFloors.Add(level);
                return;
            }
            context.Monitor.Log($"Loaded level postfix {__instance.getMineArea(level)} {level}");

            if (__instance.getMineArea(level) == 121)
            {
                double treasureChance = 0.01;
                treasureChance += Game1.player.team.AverageDailyLuck(Game1.currentLocation) / 10.0 + Game1.player.team.AverageLuckLevel(Game1.currentLocation) / 100.0;
                context.Monitor.Log($"checking for treasure level chance: {treasureChance * Config.TreasureChestFloorMultiplier - treasureChance}");
                if (Game1.random.NextDouble() < treasureChance * Config.TreasureChestFloorMultiplier - treasureChance)
                {
                    context.Monitor.Log("Creating treasure floor");
                    treasureFloors.Add(level);
                    ___netIsTreasureRoom.Value = true;
                    __instance.loadedMapNumber = 10;
                    if (___netIsSlimeArea || ___netIsDinoArea)
                    {
                        RevertMapImageSource(ref ___mapImageSource, ref ___loadedDarkArea, level, __instance.getMineArea(-1), __instance.getMineArea(level), __instance.loadedMapNumber);
                    }
                    return;
                }
            }

            bool IsMonsterFloor = Game1.random.Next(0, 100) < Config.PercentChanceMonsterFloor;

            if (IsMonsterFloor)
            {
                if (IsBelowMinFloorsApart(level))
                {
                    if (___netIsSlimeArea || ___netIsDinoArea)
                    {
                        RevertMapImageSource(ref ___mapImageSource, ref ___loadedDarkArea, level, __instance.getMineArea(-1), __instance.getMineArea(level), __instance.loadedMapNumber);
                    }
                    ___netIsDinoArea.Value    = false;
                    ___netIsSlimeArea.Value   = false;
                    ___netIsMonsterArea.Value = false;
                    return;
                }

                monsterFloors.Add(level);

                if (___netIsQuarryArea)
                {
                    ___netIsMonsterArea.Value = true;
                }
                else
                {
                    int roll = Game1.random.Next(0, 100);
                    ___netIsMonsterArea.Value = true;
                    if (__instance.getMineArea(-1) == 121)
                    {
                        string[] chances     = Config.SlimeDinoMonsterSplitPercents.Split(':');
                        int      slimeChance = int.Parse(chances[0]);
                        int      dinoChance  = int.Parse(chances[1]);
                        if (roll < slimeChance)
                        {
                            ___netIsDinoArea.Value    = false;
                            ___netIsSlimeArea.Value   = true;
                            ___netIsMonsterArea.Value = false;
                        }
                        else if (roll < dinoChance + slimeChance)
                        {
                            ___netIsDinoArea.Value    = true;
                            ___netIsSlimeArea.Value   = false;
                            ___netIsMonsterArea.Value = false;
                            ___mapImageSource.Value   = "Maps\\Mines\\mine_dino";
                        }
                        else if (___netIsSlimeArea || ___netIsDinoArea)
                        {
                            RevertMapImageSource(ref ___mapImageSource, ref ___loadedDarkArea, level, __instance.getMineArea(-1), __instance.getMineArea(level), __instance.loadedMapNumber);
                        }
                    }
                    else
                    {
                        string[] chances = Config.SlimeMonsterSplitPercents.Split(':');
                        if (roll < int.Parse(chances[0]))
                        {
                            ___netIsDinoArea.Value    = false;
                            ___netIsSlimeArea.Value   = true;
                            ___netIsMonsterArea.Value = false;
                            ___mapImageSource.Value   = "Maps\\Mines\\mine_slime";
                        }
                    }
                }
            }
            else
            {
                ___netIsMonsterArea.Value = false;
                ___netIsDinoArea.Value    = false;
                ___netIsSlimeArea.Value   = false;
            }
        }
Exemple #24
0
 public virtual void OnStructureValueChanged(NetBool field, bool old_value, bool new_value)
 {
     _dirty = true;
 }
Exemple #25
0
        private static bool DrawPrefix(FruitTree __instance, float ___shakeRotation, float ___shakeTimer, float ___alpha, List <Leaf> ___leaves, NetBool ___falling, SpriteBatch spriteBatch, Vector2 tileLocation)
        {
            if (__instance.modData.ContainsKey("AlternativeTextureName"))
            {
                var textureModel = AlternativeTextures.textureManager.GetSpecificTextureModel(__instance.modData["AlternativeTextureName"]);
                if (textureModel is null)
                {
                    return(true);
                }

                var textureVariation = Int32.Parse(__instance.modData["AlternativeTextureVariation"]);
                if (textureVariation == -1 || AlternativeTextures.modConfig.IsTextureVariationDisabled(textureModel.GetId(), textureVariation))
                {
                    return(true);
                }

                string season = Game1.GetSeasonForLocation(__instance.currentLocation);
                if ((bool)__instance.greenHouseTileTree)
                {
                    spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2(tileLocation.X * 64f, tileLocation.Y * 64f)), new Rectangle(669, 1957, 16, 16), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 1E-08f);
                }

                var textureOffset = textureModel.GetTextureOffset(textureVariation);
                if ((int)__instance.growthStage < 4)
                {
                    Vector2   positionOffset = new Vector2((float)Math.Max(-8.0, Math.Min(64.0, Math.Sin((double)(tileLocation.X * 200f) / (Math.PI * 2.0)) * -16.0)), (float)Math.Max(-8.0, Math.Min(64.0, Math.Sin((double)(tileLocation.X * 200f) / (Math.PI * 2.0)) * -16.0))) / 2f;
                    Rectangle sourceRect     = Rectangle.Empty;
                    switch ((int)__instance.growthStage)
                    {
                    case 0:
                        sourceRect = new Rectangle(0, textureVariation * 5 * 16, 48, 80);
                        break;

                    case 1:
                        sourceRect = new Rectangle(48, textureVariation * 5 * 16, 48, 80);
                        break;

                    case 2:
                        sourceRect = new Rectangle(96, textureVariation * 5 * 16, 48, 80);
                        break;

                    default:
                        sourceRect = new Rectangle(144, textureVariation * 5 * 16, 48, 80);
                        break;
                    }

                    spriteBatch.Draw(textureModel.GetTexture(textureVariation), Game1.GlobalToLocal(Game1.viewport, new Vector2(tileLocation.X * 64f + 32f + positionOffset.X, tileLocation.Y * 64f - (float)sourceRect.Height + 128f + positionOffset.Y)), sourceRect, Color.White, ___shakeRotation, new Vector2(24f, 80f), 4f, __instance.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (float)__instance.getBoundingBox(tileLocation).Bottom / 10000f - tileLocation.X / 1000000f);
                }
                else
                {
                    if (!__instance.stump || (bool)___falling)
                    {
                        if (!___falling)
                        {
                            spriteBatch.Draw(textureModel.GetTexture(textureVariation), Game1.GlobalToLocal(Game1.viewport, new Vector2(tileLocation.X * 64f + 32f, tileLocation.Y * 64f + 64f)), new Rectangle((12 + (__instance.greenHouseTree ? 1 : Utility.getSeasonNumber(season)) * 3) * 16, textureVariation * 5 * 16 + 64, 48, 16), ((int)__instance.struckByLightningCountdown > 0) ? (Color.Gray * ___alpha) : (Color.White * ___alpha), 0f, new Vector2(24f, 16f), 4f, __instance.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 1E-07f);
                        }
                        spriteBatch.Draw(textureModel.GetTexture(textureVariation), Game1.GlobalToLocal(Game1.viewport, new Vector2(tileLocation.X * 64f + 32f, tileLocation.Y * 64f + 64f)), new Rectangle((12 + (__instance.greenHouseTree ? 1 : Utility.getSeasonNumber(season)) * 3) * 16, textureVariation * 5 * 16, 48, 64), ((int)__instance.struckByLightningCountdown > 0) ? (Color.Gray * ___alpha) : (Color.White * ___alpha), ___shakeRotation, new Vector2(24f, 80f), 4f, __instance.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (float)__instance.getBoundingBox(tileLocation).Bottom / 10000f + 0.001f - tileLocation.X / 1000000f);
                    }
                    if ((float)__instance.health >= 1f || (!___falling && (float)__instance.health > -99f))
                    {
                        spriteBatch.Draw(textureModel.GetTexture(textureVariation), Game1.GlobalToLocal(Game1.viewport, new Vector2(tileLocation.X * 64f + 32f + ((___shakeTimer > 0f) ? ((float)Math.Sin(Math.PI * 2.0 / (double)___shakeTimer) * 2f) : 0f), tileLocation.Y * 64f + 64f)), new Rectangle(384, textureVariation * 5 * 16 + 48, 48, 32), ((int)__instance.struckByLightningCountdown > 0) ? (Color.Gray * ___alpha) : (Color.White * ___alpha), 0f, new Vector2(24f, 32f), 4f, __instance.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, ((bool)__instance.stump && !___falling) ? ((float)__instance.getBoundingBox(tileLocation).Bottom / 10000f) : ((float)__instance.getBoundingBox(tileLocation).Bottom / 10000f - 0.001f - tileLocation.X / 1000000f));
                    }
                    for (int i = 0; i < (int)__instance.fruitsOnTree; i++)
                    {
                        switch (i)
                        {
                        case 0:
                            spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2(tileLocation.X * 64f - 64f + tileLocation.X * 200f % 64f / 2f, tileLocation.Y * 64f - 192f - tileLocation.X % 64f / 3f)), Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, ((int)__instance.struckByLightningCountdown > 0) ? 382 : ((int)__instance.indexOfFruit), 16, 16), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, (float)__instance.getBoundingBox(tileLocation).Bottom / 10000f + 0.002f - tileLocation.X / 1000000f);
                            break;

                        case 1:
                            spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2(tileLocation.X * 64f + 32f, tileLocation.Y * 64f - 256f + tileLocation.X * 232f % 64f / 3f)), Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, ((int)__instance.struckByLightningCountdown > 0) ? 382 : ((int)__instance.indexOfFruit), 16, 16), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, (float)__instance.getBoundingBox(tileLocation).Bottom / 10000f + 0.002f - tileLocation.X / 1000000f);
                            break;

                        case 2:
                            spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2(tileLocation.X * 64f + tileLocation.X * 200f % 64f / 3f, tileLocation.Y * 64f - 160f + tileLocation.X * 200f % 64f / 3f)), Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, ((int)__instance.struckByLightningCountdown > 0) ? 382 : ((int)__instance.indexOfFruit), 16, 16), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.FlipHorizontally, (float)__instance.getBoundingBox(tileLocation).Bottom / 10000f + 0.002f - tileLocation.X / 1000000f);
                            break;
                        }
                    }
                }
                foreach (Leaf j in ___leaves)
                {
                    spriteBatch.Draw(textureModel.GetTexture(textureVariation), Game1.GlobalToLocal(Game1.viewport, j.position), new Rectangle((24 + Utility.getSeasonNumber(season)) * 16, textureVariation * 5 * 16, 8, 8), Color.White, j.rotation, Vector2.Zero, 4f, SpriteEffects.None, (float)__instance.getBoundingBox(tileLocation).Bottom / 10000f + 0.01f);
                }

                return(false);
            }
            return(true);
        }
Exemple #26
0
 public void onActivationChanged(NetBool field, bool old_value, bool new_value)
 {
     updateActivationVisuals();
 }
        protected override void ReadDelta(BinaryReader reader, NetVersion version)
        {
            //Checks to see if the current animation is nothing, aka null.
            NetBool isNull = new NetBool();

            isNull.Read(reader, version);
            bool valueIsNull = isNull.Value;

            if (isNull)
            {
                NetTexture2DExtended nullTexture = new NetTexture2DExtended();
                nullTexture.Read(reader, version);

                NetAnimation nullAnimation = new NetAnimation();
                nullAnimation.Read(reader, version);

                Value.setExtendedTexture(nullTexture.Value);
                Value.defaultDrawFrame = nullAnimation.Value;
                return;
            }


            NetString currentAnimationName = new NetString();

            currentAnimationName.Read(reader, version);

            NetInt currentIndex = new NetInt();

            currentIndex.Read(reader, version);

            NetTexture2DExtended text = new NetTexture2DExtended();

            text.Read(reader, version);

            NetAnimation defaultAnimation = new NetAnimation();

            defaultAnimation.Read(reader, version);

            NetBool enabled = new NetBool();

            enabled.Read(reader, version);

            NetString data = new NetString();

            data.Read(reader, version);

            Value.setExtendedTexture(text.Value);
            Value.defaultDrawFrame = defaultAnimation.Value;
            Value.enabled          = enabled.Value;
            //Try and prevent unnecessary parsing.
            if (Value.animations == null && !String.IsNullOrEmpty(Value.animationDataString))
            {
                Value.animations = Animations.AnimationManager.parseAnimationsFromXNB(data.Value);
            }
            if (!String.IsNullOrEmpty(data.Value))
            {
                Value.setAnimation(currentAnimationName.Value, currentIndex.Value);
            }
            else
            {
                Value.currentAnimation = defaultDrawFrame.Value;
            }
        }
Exemple #28
0
 private static void Before_ShadowShaman_behaviorAtGameTick(SquidKid __instance, ref NetBool ___casting)
 {
     if (IsLovedMonster(__instance))
     {
         ___casting.Value = false;
     }
 }
        /// <summary>Patch for Rascal slingshot damage increase with travel time.</summary>
        private static bool BasicProjectileBehaviorOnCollisionWithMonsterPrefix(ref BasicProjectile __instance, ref NetBool ___damagesMonsters, ref NetCharacterRef ___theOneWhoFiredMe, ref int ___travelTime, NPC n, GameLocation location)
        {
            try
            {
                if (!___damagesMonsters || n is not Monster)
                {
                    return(true);                                                         // run original logic
                }
                var who = ___theOneWhoFiredMe.Get(location) is Farmer
                                        ? ___theOneWhoFiredMe.Get(location) as Farmer
                                        : Game1.player;

                if (!Utility.SpecificPlayerHasProfession("Rascal", who))
                {
                    return(true);                                                                     // run original logic
                }
                AwesomeProfessions.Reflection.GetMethod(__instance, name: "explosionAnimation")?.Invoke(location);
                var damageToMonster = (int)(__instance.damageToFarmer.Value * Utility.GetRascalBonusDamageForTravelTime(___travelTime));
                location.damageMonster(n.GetBoundingBox(), damageToMonster, damageToMonster + 1, isBomb: false, who);

                return(false);                // don't run original logic
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed in {nameof(BasicProjectileBehaviorOnCollisionWithMonsterPrefix)}:\n{ex}", LogLevel.Error);
                return(true);                // default to original logic
            }
        }
        /// <summary>Raised after the game begins a new day (including when the player loads a save).</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        public void OnDayStarted(object sender, DayStartedEventArgs e)
        {
            try
            {
                // reset data
                this.IsUpLate = false;

                // transition to the next day
                if (this.ShouldResetPlayerAfterCollapseNow)
                {
                    this.ShouldResetPlayerAfterCollapseNow = false;

                    if (this.Config.KeepStaminaAfterCollapse)
                    {
                        Game1.player.stamina = this.PreCollapseStamina;
                    }
                    if (this.Config.KeepHealthAfterCollapse)
                    {
                        Game1.player.health = this.PreCollapseHealth;
                    }
                    if (this.Config.KeepPositionAfterCollapse)
                    {
                        if (!Game1.weddingToday)
                        {
                            Game1.warpFarmer(this.PreCollapseMap, this.PreCollapseTile.X, this.PreCollapseTile.Y, false);
                            foreach (var v in PostWarpCharacter)
                            {
                                v.Value.Invoke();
                            }
                        }
                    }

                    if (this.horse != null && this.shouldWarpHorse)
                    {
                        Game1.warpCharacter(this.horse, Game1.player.currentLocation, Game1.player.position);
                        this.shouldWarpHorse = false;
                    }
                    if (this.isInSwimSuit)
                    {
                        Game1.player.changeIntoSwimsuit();
                    }
                    if (this.isBathing)
                    {
                        Game1.player.swimming.Value = true;
                    }

                    //Reflection to ensure that the railroad becomes properly unblocked.
                    if (Game1.dayOfMonth == 1 && Game1.currentSeason == "summer" && Game1.year == 1)
                    {
                        Mountain mountain = (Mountain)Game1.getLocationFromName("Mountain");

                        NetBool netBool2 = this.Helper.Reflection.GetField <NetBool>(mountain, "railroadAreaBlocked").GetValue();
                        netBool2.Value = false;

                        this.Helper.Reflection.GetField <Rectangle>(mountain, "railroadBlockRect").SetValue(Rectangle.Empty);

                        this.eve = new StardewValley.Events.SoundInTheNightEvent(4);
                        this.eve.setUp();
                        this.eve.makeChangesToLocation();
                    }
                }

                if (Game1.currentSeason != "spring" && Game1.year >= 1)
                {
                    this.clearRailRoadBlock();
                }

                // delete annoying charge messages (if only I could do this with mail IRL)
                if (this.Config.SkipCollapseMail)
                {
                    string[] validMail = Game1.mailbox
                                         .Where(p => !p.Contains("passedOut"))
                                         .ToArray();

                    Game1.mailbox.Clear();
                    foreach (string mail in validMail)
                    {
                        Game1.mailbox.Add(mail);
                    }
                }

                this.JustStartedNewDay = true;
            }
            catch (Exception ex)
            {
                this.Monitor.Log(ex.ToString(), LogLevel.Error);
                this.WriteErrorLog();
            }
        }