コード例 #1
0
        private NetCollection <NPC> GetVillagers()
        {
            var allNpcs      = new NetCollection <NPC>();
            var locationList = Context.IsMainPlayer
                                ? this.Helper.Multiplayer.GetActiveLocations().Concat(Game1.locations)
                                : this.Helper.Multiplayer.GetActiveLocations();

            foreach (GameLocation location in locationList)
            {
                foreach (NPC npc in location.characters)
                {
                    if (npc == null)
                    {
                        continue;
                    }
                    if (!allNpcs.Contains(npc) &&
                        !ModConstants.ExcludedVillagers.Contains(npc.Name) &&
                        npc.isVillager())
                    {
                        allNpcs.Add(npc);
                    }
                }
            }

            return(allNpcs);
        }
コード例 #2
0
        public override void OnReleased()
        {
            base.OnReleased();

            if (_menuInstaller != null)
            {
                Object.Destroy(_menuInstaller);
                _menuInstaller = null;
            }

            if (_roadsInstaller != null)
            {
                Object.Destroy(_roadsInstaller);
                _roadsInstaller = null;
            }

            if (_roads != null)
            {
                Object.Destroy(_roads);
                _roads = null;
            }

            if (_props != null)
            {
                Object.Destroy(_props);
                _props = null;
            }

            if (_container != null)
            {
                Object.Destroy(_container);
                _container = null;
            }
        }
コード例 #3
0
        public override void OnReleased()
        {
            base.OnReleased();

            if (_isReleased)
            {
                return;
            }

            if (_initalizer != null)
            {
                Object.Destroy(_initalizer);
                _initalizer = null;
            }

            if (_newRoads != null)
            {
                Object.Destroy(_newRoads);
                _newRoads = null;
            }

            if (_container != null)
            {
                Object.Destroy(_container);
                _container = null;
            }

            _isReleased = true;
        }
コード例 #4
0
        public override void behaviorAtGameTick(GameTime time)
        {
            base.behaviorAtGameTick(time);


            if (Health <= 0)
            {
                return;
            }

            this.lastGhost  = Math.Max(0f, this.lastGhost - (float)time.ElapsedGameTime.Milliseconds);
            this.lastDebuff = Math.Max(0f, this.lastDebuff - (float)time.ElapsedGameTime.Milliseconds);

            if (withinPlayerThreshold(10))
            {
                if (lastDebuff == 0f)
                {
                    Vector2 velocityTowardPlayer = Utility.getVelocityTowardPlayer(this.GetBoundingBox().Center, 15f, base.Player);
                    if (ModEntry.IsLessThanHalfHealth(this))
                    {
                        for (int i = 0; i < 12; i++)
                        {
                            Vector2 trajectory = ModEntry.VectorFromDegree(i * 30) * 10f;
                            currentLocation.projectiles.Add(new BossProjectile((int)Math.Round(20 * difficulty), 9, 3, 4, 0f, trajectory.X, trajectory.Y, getStandingPosition(), "", "", true, false, currentLocation, this, false, null, 19));
                        }
                    }
                    else
                    {
                        currentLocation.projectiles.Add(new BossProjectile((int)Math.Round(20 * difficulty), 9, 3, 4, 0f, velocityTowardPlayer.X, velocityTowardPlayer.Y, getStandingPosition(), "", "", true, false, currentLocation, this, false, null, 19));
                    }


                    this.lastDebuff = Game1.random.Next(3000, 6000);
                }
                if (lastGhost == 0f)
                {
                    int ghosts = 0;
                    using (NetCollection <NPC> .Enumerator enumerator = currentLocation.characters.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            NPC j = enumerator.Current;
                            if (j is ToughGhost)
                            {
                                ghosts++;
                            }
                        }
                    }
                    if (ghosts < (Health < MaxHealth / 2 ? this.MaxGhosts * 2 : this.MaxGhosts))
                    {
                        GameLocation aLocation = currentLocation;
                        currentLocation.characters.Add(new ToughGhost(Position, difficulty)
                        {
                            focusedOnFarmers = true
                        });
                        this.lastGhost = (float)Game1.random.Next(3000, 80000);
                    }
                }
            }
        }
コード例 #5
0
ファイル: Extensions.cs プロジェクト: TomWaa/SelfCheckout
        public static NPC Find(this NetCollection <NPC> npcs, string name)
        {
            NPC npc;

            using (NetCollection <NPC> .Enumerator enumarator = npcs.GetEnumerator())
            {
                while (true)
                {
                    if (enumarator.MoveNext())
                    {
                        NPC npc2 = enumarator.Current;
                        if (npc2.Name != name)
                        {
                            continue;
                        }

                        npc = npc2;
                    }
                    else
                    {
                        return(null);
                    }

                    break;
                }
            }

            return(npc);
        }
コード例 #6
0
        /*
         * In here I'm changing the prefabs to have my classes. This way, every time the game instantiates
         * a prefab that I've changed, that object will run my code.
         * The prefabs aren't available at the moment of creation of this class, that's why I keep trying to
         * run it on update. I want to make sure I make the switch as soon as they exist to prevent the game
         * from instantianting objects without my code.
         */
        void TryReplacePrefabs()
        {
            try {
                NetCollection     beautificationNetCollection = GameObject.Find("Beautification").GetComponent <NetCollection>();
                VehicleCollection garbageVehicleCollection    = GameObject.Find("Garbage").GetComponent <VehicleCollection>();
                VehicleCollection policeVehicleCollection     = GameObject.Find("Police Department").GetComponent <VehicleCollection>();
                //VehicleCollection publicTansportVehicleCollection = GameObject.Find("Public Transport").GetComponent<VehicleCollection>();
                VehicleCollection healthCareVehicleCollection     = GameObject.Find("Health Care").GetComponent <VehicleCollection>();
                VehicleCollection fireDepartmentVehicleCollection = GameObject.Find("Fire Department").GetComponent <VehicleCollection>();

                // Localization
                UpdateLocalization();

                // roads
                PedestrianZoningPathAI.Initialize(beautificationNetCollection, transform);
                PedestrianZoningBridgeAI.Initialize(beautificationNetCollection, transform);

                // vehicles
                CustomGarbageTruckAI.Initialize(garbageVehicleCollection, transform);
                CustomAmbulanceAI.Initialize(healthCareVehicleCollection, transform);
                //CustomBusAI.Initialize(publicTansportVehicleCollection, transform);
                CustomFireTruckAI.Initialize(fireDepartmentVehicleCollection, transform);
                CustomHearseAI.Initialize(healthCareVehicleCollection, transform);
                CustomPoliceCarAI.Initialize(policeVehicleCollection, transform);

                m_initialized = true;
            } catch (KeyNotFoundException knf) {
#if DEBUG
                System.IO.File.AppendAllText("Debug.txt", "Error trying to initialize custom prefabs: " + knf.Message + "\n");
                m_initialized = true;
#endif
            } catch (Exception) {}
        }
コード例 #7
0
        public override void OnReleased()
        {
            base.OnReleased();

            if (_isReleased)
            {
                return;
            }

            if (_initalizer != null)
            {
                Object.Destroy(_initalizer);
                _initalizer = null;
            }

            if (_newRoads != null)
            {
                Object.Destroy(_newRoads);
                _newRoads = null;
            }

            if (_container != null)
            {
                Object.Destroy(_container);
                _container = null;
            }

            _isReleased = true;
        }
コード例 #8
0
        public override Item GetItemForInput(InputPipeNode input, int flux)
        {
            Item item = null;

            if (input != null)
            {
                NetCollection <Item> itemList = Farm.getShippingBin(Game1.MasterPlayer);
                int index = itemList.Count - 1;
                if (CanSendItems() && Farm.lastItemShipped != null)
                {
                    if (input.HasFilter())
                    {
                        if (input.Filter.Any(i => i.Name.Equals(itemList[index].Name)))
                        {
                            item = TryExtractItem(input.ConnectedContainer, itemList);
                        }
                    }
                    else
                    {
                        item = TryExtractItem(input.ConnectedContainer, itemList);
                    }
                }
            }
            return(item);
        }
コード例 #9
0
        private void OnShippingBinUpdate(object sender, EventArgs e)
        {
            if (!Game1.hasLoadedGame)
            {
                return;
            }

            //every update, store what is in the bin. Then at night when they see the shipping results we have the items ready
            NetCollection <Item> previous = null;

            if (Game1.activeClickableMenu == null)
            {
                foreach (Farmer farmer in Game1.getAllFarmers())
                {
                    int itemCount = (farmerItems.ContainsKey(farmer)) ? farmerItems[farmer].Count : 0;
                    NetCollection <Item> current = Game1.getFarm().getShippingBin(farmer);
                    if (current != previous)
                    {
                        farmerItems[farmer] = new List <Item>(current);
                    }
                    else
                    {
                        farmerItems[farmer] = new List <Item>();
                    }
                    previous = current;


                    if (farmerItems[farmer].Count > itemCount)
                    {
                        Log("Added " + (farmerItems[farmer].Count - itemCount) + " items to ship for " + farmer.name);
                    }
                }
            }
        }
コード例 #10
0
        public static bool GameLocation_performAction_Prefix(GameLocation __instance, string action, Farmer who, ref bool __result, Location tileLocation)
        {
            try
            {
                if (action != null && who.IsLocalPlayer)
                {
                    string[] actionParams = action.Split(new char[]
                    {
                        ' '
                    });
                    string text    = actionParams[0];
                    Regex  pattern = new Regex(@"Crib[0-9][0-9]*");
                    if (pattern.IsMatch(text))
                    {
                        int crib = int.Parse(text.Substring(4));
                        Monitor.Log($"Acting on crib {crib+1}");

                        Microsoft.Xna.Framework.Rectangle rect = new Microsoft.Xna.Framework.Rectangle((ModEntry.config.ExistingKidsRoomOffsetX + 15) * 64 + (3 * crib * 64), (ModEntry.config.ExistingKidsRoomOffsetY + 2) * 64, 3 * 64, 4 * 64);
                        using (NetCollection <NPC> .Enumerator enumerator = __instance.characters.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                NPC j = enumerator.Current;
                                if (j is Child)
                                {
                                    if (rect.Intersects(j.GetBoundingBox()))
                                    {
                                        if ((j as Child).Age == 1)
                                        {
                                            Monitor.Log($"Tossing {j.Name}");
                                            (j as Child).toss(who);
                                        }
                                        else if ((j as Child).Age == 0)
                                        {
                                            Monitor.Log($"{j.Name} is sleeping");
                                            Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\Locations:FarmHouse_Crib_NewbornSleeping", j.displayName)));
                                        }
                                        else if ((j as Child).isInCrib() && (j as Child).Age == 2)
                                        {
                                            Monitor.Log($"acting on {j.Name}");
                                            return(j.checkAction(who, __instance));
                                        }
                                        __result = true;
                                        return(false);
                                    }
                                }
                            }
                        }
                        __result = true;
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed in {nameof(ManorHouse_performAction_Prefix)}:\n{ex}", LogLevel.Error);
            }
            return(true);
        }
コード例 #11
0
 public static void FarmerTeam_NewDay_Postfix(FarmerTeam __instance, NetCollection <Item> __state)
 {
     __instance.grangeDisplay.Clear();
     foreach (Item item in __state)
     {
         __instance.grangeDisplay.Add(item);
     }
 }
コード例 #12
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="location">The location whose shipping bin to manage.</param>
 /// <param name="mode">The type of shipping bin menu to create.</param>
 public ShippingBinContainer(GameLocation location, ShippingBinMode mode)
 {
     this.Location    = location;
     this.Farm        = location as Farm ?? Game1.getFarm();
     this.ShippingBin = this.Farm.getShippingBin(Game1.player);
     this.Data        = new ContainerData(location.modData, discriminator: ShippingBinContainer.ModDataDiscriminator);
     this.Mode        = mode;
 }
コード例 #13
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="location">The location whose shipping bin to manage.</param>
 /// <param name="dataHelper">An API for reading and storing local mod data.</param>
 /// <param name="mode">The type of shipping bin menu to create.</param>
 public ShippingBinContainer(GameLocation location, IDataHelper dataHelper, ShippingBinMode mode)
 {
     this.DataHelper  = dataHelper;
     this.Location    = location;
     this.Farm        = location as Farm ?? Game1.getFarm();
     this.ShippingBin = this.Farm.getShippingBin(Game1.player);
     this.Data        = ContainerData.FromModData(location.modData, defaultInternalName: null, discriminator: ShippingBinContainer.ModDataDiscriminator);
     this.Mode        = mode;
 }
コード例 #14
0
 private void ButtonPressed(object sender, ButtonPressedEventArgs e)
 {
     if (e.Button == this.Config.UpdateGreenhouses && Context.IsMainPlayer)
     {
         NetCollection <Building> ToBuild = new NetCollection <Building>();
         foreach (Building building in Game1.getFarm().buildings)
         {
             bool create = true;
             if (building.buildingType.Value.Contains("Cabin"))
             {
                 foreach (Building greenhouse in Game1.getFarm().buildings)
                 {
                     if (greenhouse.buildingType.Value.Equals("Greenhouse") && greenhouse.owner.Value == (building.indoors.Value as Cabin).getFarmhand().Value.UniqueMultiplayerID)
                     {
                         create = false;
                         break;
                     }
                 }
                 if (create)
                 {
                     ToBuild.Add(CreateGreenhouse(building));
                 }
             }
         }
         foreach (Building building in ToBuild)
         {
             Game1.getFarm().buildings.Add(building);
         }
         Game1.chatBox.addMessage("Greanhouses Created: " + ToBuild.Count.ToString(), Color.White);
         NetCollection <Building> ToDestroy = new NetCollection <Building>();
         foreach (Building building in Game1.getFarm().buildings)
         {
             bool destroy = true;
             if (building.buildingType.Value.Equals("Greenhouse"))
             {
                 foreach (Building cabin in Game1.getFarm().buildings)
                 {
                     if (cabin.buildingType.Value.Contains("Cabin") && building.owner.Value == (cabin.indoors.Value as Cabin).getFarmhand().Value.UniqueMultiplayerID)
                     {
                         destroy = false;
                         break;
                     }
                 }
                 if (destroy)
                 {
                     ToDestroy.Add(building);
                 }
             }
         }
         foreach (Building building in ToDestroy)
         {
             Game1.getFarm().buildings.Remove(building);
         }
         Game1.chatBox.addMessage("Greanhouses Removed: " + ToBuild.Count.ToString(), Color.White);
     }
 }
コード例 #15
0
        } = false;                                         // Automate can't read the shipping bin settings


        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="farm">The farm whose shipping bin to manage.</param>
        /// <param name="dataHelper">An API for reading and storing local mod data.</param>
        public ShippingBinContainer(Farm farm, IDataHelper dataHelper)
        {
            this.DataHelper     = dataHelper;
            this.Farm           = farm;
            this.ShippingBin    = farm.getShippingBin(Game1.player);
            this.IsDataEditable = Context.IsMainPlayer;
            this.Data           = this.IsDataEditable
                ? dataHelper.ReadSaveData <ContainerData>(this.DataKey) ?? new ContainerData(defaultInternalName: null)
                : new ContainerData(defaultInternalName: null);
        }
コード例 #16
0
        public static void Initialize(NetCollection collection, Transform customPrefabs)
        {
            if (sm_initialized)
            {
                return;
            }

            Initialize(collection, customPrefabs, "Pedestrian Pavement", "Zonable Pedestrian Pavement");
            Initialize(collection, customPrefabs, "Pedestrian Gravel", "Zonable Pedestrian Gravel");

            sm_initialized = true;
        }
コード例 #17
0
        public override void OnReleased()
        {
            base.OnReleased();

            if (_isReleased)
            {
                return;
            }

            if (_initializer != null)
            {
                Object.Destroy(_initializer);
                _initializer = null;
            }

            if (_localizationInstaller != null)
            {
                Object.Destroy(_localizationInstaller);
                _localizationInstaller = null;
            }

            if (_assetsInstaller != null)
            {
                Object.Destroy(_assetsInstaller);
                _assetsInstaller = null;
            }

            if (_roadsInstaller != null)
            {
                Object.Destroy(_roadsInstaller);
                _roadsInstaller = null;
            }

            if (_menusInstaller != null)
            {
                Object.Destroy(_menusInstaller);
                _menusInstaller = null;
            }

            if (_newRoads != null)
            {
                Object.Destroy(_newRoads);
                _newRoads = null;
            }

            if (_container != null)
            {
                Object.Destroy(_container);
                _container = null;
            }

            _isReleased = true;
        }
コード例 #18
0
        public static void Initialize(NetCollection collection, Transform customPrefabs)
        {
            if (sm_initialized)
            {
                return;
            }

            Initialize(collection, customPrefabs, "Large Road Bridge", "Large Road Bridge With Bus Lanes");
            Initialize(collection, customPrefabs, "Large Road Elevated", "Large Road Elevated With Bus Lanes");

            sm_initialized = true;
        }
コード例 #19
0
        public static NPC Find(this NetCollection <NPC> npcs, string name)
        {
            foreach (NPC npc in npcs)
            {
                if (npc.Name == name)
                {
                    return(npc);
                }
            }

            return(null);
        }
コード例 #20
0
        public static void Initialize(NetCollection collection, Transform customPrefabs)
        {
            if (sm_initialized)
            {
                return;
            }

            Initialize(collection, customPrefabs, "Large Road", "Large Road With Bus Lanes");
            //Initialize(collection, customPrefabs, "Large Road Decoration Trees", "Large Road Decoration Trees With Bus Lanes");
            //Initialize(collection, customPrefabs, "Large Road Decoration Grass", "Large Road Decoration Grass With Bus Lanes");

            sm_initialized = true;
        }
コード例 #21
0
        /// <summary>
        /// Clones all monsters in the given volcano dungeon and places them at the same place as their original
        /// </summary>
        /// <param name="dungeon"></param>
        private void DoubleMonstersInVolcanoDungeon(VolcanoDungeon dungeon)
        {
            var original_characters = new NetCollection <NPC>(dungeon.characters);

            foreach (var character in original_characters)
            {
                // exclude player, dwarf and whatever else might creep up here
                if (character is Monster monster)
                {
                    this.CloneVolcanoDungeonMonster(dungeon, monster);
                }
            }
        }
コード例 #22
0
        public static void Initialize(NetCollection collection, VehicleCollection vehicleCollection, TransportCollection transportCollection, Transform customPrefabs)
        {
            if (sm_initialized)
            {
                return;
            }

            Initialize(collection, transportCollection, customPrefabs, "Bus Line", "Bus");
            //Initialize(collection, transportCollection, customPrefabs, "Metro Line", "Metro");


            sm_initialized = true;
        }
コード例 #23
0
        private static void InitializeNewRoads(NetCollection newRoads)
        {
            Loading.QueueAction(() =>
            {
                Debug.Log("NExt: Build NetworkExtensions");


                // Builders -----------------------------------------------------------------------
                var newInfos = new List <NetInfo>();

                foreach (var builder in Mod.NetInfoBuilders)
                {
                    try
                    {
                        newInfos.AddRange(builder.Build());
                    }
                    catch (Exception ex)
                    {
                        Debug.Log(string.Format("NExt: Crashed-Network builders {0}", builder));
                        Debug.Log("NExt: " + ex.Message);
                        Debug.Log("NExt: " + ex.ToString());
                    }
                }

                if (newInfos.Count > 0)
                {
                    newRoads.m_prefabs = newInfos.ToArray();

                    PrefabCollection <NetInfo> .InitializePrefabs(newRoads.name, newRoads.m_prefabs, new string[] { });
                    PrefabCollection <NetInfo> .BindPrefabs();
                }


                // Modifiers ----------------------------------------------------------------------
                foreach (var modifier in Mod.NetInfoModifiers)
                {
                    try
                    {
                        modifier.ModifyExistingNetInfo();
                    }
                    catch (Exception ex)
                    {
                        Debug.Log(string.Format("NExt: Crashed-Network modifiers {0}", modifier));
                        Debug.Log("NExt: " + ex.Message);
                        Debug.Log("NExt: " + ex.ToString());
                    }
                }

                Debug.Log("NExt: Finished installing components");
            });
        }
コード例 #24
0
ファイル: BugBoss.cs プロジェクト: G3ls0n/StardewValleyMods
        public override void behaviorAtGameTick(GameTime time)
        {
            base.behaviorAtGameTick(time);

            if (Health <= 0)
            {
                return;
            }

            this.lastFly    = Math.Max(0f, this.lastFly - (float)time.ElapsedGameTime.Milliseconds);
            this.lastDebuff = Math.Max(0f, this.lastDebuff - (float)time.ElapsedGameTime.Milliseconds);

            if (withinPlayerThreshold(10))
            {
                if (lastDebuff == 0f)
                {
                    Vector2 velocityTowardPlayer = Utility.getVelocityTowardPlayer(this.GetBoundingBox().Center, 15f, base.Player);

                    base.currentLocation.projectiles.Add(new DebuffingProjectile(14, 2, 4, 4, 0.196349546f, velocityTowardPlayer.X, velocityTowardPlayer.Y, new Vector2((float)this.GetBoundingBox().X, (float)this.GetBoundingBox().Y), base.currentLocation, this));
                    this.lastDebuff = Game1.random.Next(3000, 6000);
                }
                if (lastFly == 0f)
                {
                    int flies = 0;
                    using (NetCollection <NPC> .Enumerator enumerator = currentLocation.characters.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            NPC j = enumerator.Current;
                            if (j is ToughFly)
                            {
                                flies++;
                            }
                        }
                    }
                    if (flies < (Health < MaxHealth / 2 ? this.MaxFlies * 2 : this.MaxFlies))
                    {
                        if (Health < MaxHealth / 2)
                        {
                            Vector2 velocityTowardPlayer = Utility.getVelocityTowardPlayer(this.GetBoundingBox().Center, 15f, base.Player);
                            base.currentLocation.projectiles.Add(new DebuffingProjectile(13, 7, 4, 4, 0.196349546f, velocityTowardPlayer.X, velocityTowardPlayer.Y, new Vector2((float)this.GetBoundingBox().X, (float)this.GetBoundingBox().Y), base.currentLocation, this));
                        }
                        currentLocation.characters.Add(new ToughFly(Position, difficulty)
                        {
                            focusedOnFarmers = true
                        });
                        this.lastFly = (float)Game1.random.Next(4000, 8000);
                    }
                }
            }
        }
コード例 #25
0
        static void Initialize(NetCollection collection, Transform customPrefabs, string prefabName, string instanceName)
        {
            Debug.Log("Traffic++: Initializing " + instanceName);

            NetInfo originalLargeRoad = collection.m_prefabs.Where(p => p.name == prefabName).FirstOrDefault();

            if (originalLargeRoad == null)
            {
                throw new KeyNotFoundException(prefabName + " was not found on " + collection.name);
            }

            GameObject instance = GameObject.Instantiate <GameObject>(originalLargeRoad.gameObject);

            instance.name = instanceName;

            MethodInfo initMethod = typeof(NetCollection).GetMethod("InitializePrefabs", BindingFlags.Static | BindingFlags.NonPublic);

            if ((CSLTraffic.Options & OptionsManager.ModOptions.GhostMode) == OptionsManager.ModOptions.GhostMode)
            {
                instance.transform.SetParent(originalLargeRoad.transform.parent);
                Initializer.QueuePrioritizedLoadingAction((IEnumerator)initMethod.Invoke(null, new object[] { collection.name, new[] { instance.GetComponent <NetInfo>() }, new string[] { } }));
                sm_initialized = true;
                return;
            }

            instance.transform.SetParent(customPrefabs);
            GameObject.Destroy(instance.GetComponent <RoadAI>());
            instance.AddComponent <LargeRoadWithBusLanesAI>();

            NetInfo largeRoadWithBusLanes = instance.GetComponent <NetInfo>();

            largeRoadWithBusLanes.m_prefabInitialized = false;
            largeRoadWithBusLanes.m_netAI             = null;

            Initializer.QueuePrioritizedLoadingAction((IEnumerator)initMethod.Invoke(null, new object[] { collection.name, new[] { largeRoadWithBusLanes }, new string[] { } }));

            Initializer.QueueLoadingAction(() =>
            {
                largeRoadWithBusLanes.m_UIPriority = 20;

                largeRoadWithBusLanes.m_lanes[4].m_laneType = (NetInfo.LaneType)((byte)64);
                largeRoadWithBusLanes.m_lanes[5].m_laneType = (NetInfo.LaneType)((byte)64);

                if (Singleton <SimulationManager> .instance.m_metaData.m_invertTraffic == SimulationMetaData.MetaBool.True)
                {
                    largeRoadWithBusLanes.m_lanes[4].m_direction = NetInfo.Direction.Forward;
                    largeRoadWithBusLanes.m_lanes[5].m_direction = NetInfo.Direction.Backward;
                }
            });
        }
コード例 #26
0
ファイル: ModEntry.cs プロジェクト: doi3kimngoc/StardewMods
        private void ConvertObelisks()
        {
            NetCollection <Building> buildings = Game1.getFarm().buildings;

            for (var i = 0; i < buildings.Count; i++)
            {
                if (buildings[i].buildingType.Value == "Desert Obelisk" && !(buildings[i] is DesertObelisk))
                {
                    this.Monitor.Log($"Converting {buildings[i].GetType().Name}", LogLevel.Trace);
                    buildings[i] = new DesertObelisk(this.obeliskBlueprint,
                                                     new Vector2(buildings[i].tileX.Value, buildings[i].tileY.Value), DesertWarpX);
                }
            }
        }
コード例 #27
0
ファイル: ModEntry.cs プロジェクト: doi3kimngoc/StardewMods
        private void ClearAndSaveTempObelisks(List <DesertObelisk> saveData)
        {
            saveData.Clear();

            NetCollection <Building> buildings = Game1.getFarm().buildings;
            List <DesertObelisk>     copied    = new List <DesertObelisk>();

            copied.AddRange(buildings.Where(item => item is DesertObelisk).OfType <DesertObelisk>());
            saveData.AddRange(copied);

            foreach (DesertObelisk obelisk in copied)
            {
                buildings.Remove(obelisk);
            }
        }
コード例 #28
0
ファイル: ModEntry.cs プロジェクト: G3ls0n/StardewValleyMods
 public static Monster BossHere(GameLocation location)
 {
     using (NetCollection <NPC> .Enumerator enumerator = location.characters.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             NPC j = enumerator.Current;
             if (BossTypes.ContainsKey(j.GetType()))
             {
                 return((Monster)j);
             }
         }
     }
     return(null);
 }
コード例 #29
0
        void FindRoadPrefabs()
        {
            foreach (NetCollection collection in NetCollection.FindObjectsOfType <NetCollection>())
            {
                if (collection.name == "Road")
                {
                    foreach (NetInfo prefab in collection.m_prefabs)
                    {
                        roadPrefabNames[prefab.GetInstanceID()] = prefab.name;
                        roadPrefabs[prefab.name] = prefab;
                    }
                }
            }

            ModDebug.Log("Found " + roadPrefabs.Count + " road prefabs");
        }
コード例 #30
0
        private void SaveCreating(object sender, SaveCreatingEventArgs e)
        {
            NetCollection <Building> ToBuild = new NetCollection <Building>();

            foreach (Building building in Game1.getFarm().buildings)
            {
                if (building.buildingType.Value.Contains("Cabin"))
                {
                    ToBuild.Add(CreateGreenhouse(building));
                }
            }
            foreach (Building building in ToBuild)
            {
                Game1.getFarm().buildings.Add(building);
            }
            Game1.chatBox.addMessage("Greanhouses Created: " + ToBuild.Count.ToString(), Color.White);
        }
コード例 #31
0
        /// <summary>
        /// Exports the texture.
        /// </summary>
        /// <param name="netCollection">The net collection.</param>
        /// <param name="netInfo">The net information.</param>
        /// <param name="material">The material.</param>
        private void ExportTexture(NetCollection netCollection, NetInfo netInfo, Material material)
        {
            if (this.exportDiffuse)
            {
                this.ExportTexture(netCollection, netInfo, netInfo.m_segments[0].m_material, TextureType.MainTex);
            }

            if (this.exportACIMap)
            {
                this.ExportTexture(netCollection, netInfo, netInfo.m_segments[0].m_material, TextureType.ACIMap);
            }

            if (this.exportXYSMap)
            {
                this.ExportTexture(netCollection, netInfo, netInfo.m_segments[0].m_material, TextureType.XYSMap);
            }
        }
コード例 #32
0
        public override void OnCreated(ILoading loading)
        {
            base.OnCreated(loading);

            if (_isReleased)
            {
                _container = new GameObject(NEXT_OBJECT_NAME);

                _newRoads = _container.AddComponent<NetCollection>();
                _newRoads.name = NEWROADS_NETCOLLECTION;

                _initalizer = _container.AddComponent<ModInitializer>();
                _initalizer.NewRoads = _newRoads;
                _initalizer.InitializationCompleted += InitializationCompleted;

                _isReleased = false;
            }
        }
コード例 #33
0
        public override void OnCreated(ILoading loading)
        {
            base.OnCreated(loading);

            if (_isReleased)
            {
                if (GetPath() != PATH_NOT_FOUND)
                {
                    _container = new GameObject(REX_OBJECT_NAME);

                    _newRoads = _container.AddComponent<NetCollection>();
                    _newRoads.name = NEWROADS_NETCOLLECTION;

                    _initializer = _container.AddComponent<Initializer>();
                    _initializer.InstallationCompleted += InitializationCompleted;
                }

                _isReleased = false;
            }
        }
コード例 #34
0
        private static void InitializeNewRoads(NetCollection newRoads)
        {
            Loading.QueueAction(() =>
            {
                Debug.Log("NExt: Build NetworkExtensions");


                // Builders -----------------------------------------------------------------------
                var newInfos = new List<NetInfo>();

                foreach (var builder in Mod.NetInfoBuilders)
                {
                    try
                    {
                        newInfos.AddRange(builder.Build());
                    }
                    catch (Exception ex)
                    {
                        Debug.Log(string.Format("NExt: Crashed-Network builders {0}", builder));
                        Debug.Log("NExt: " + ex.Message);
                        Debug.Log("NExt: " + ex.ToString());
                    }
                }

                if (newInfos.Count > 0)
                {
                    newRoads.m_prefabs = newInfos.ToArray();

                    PrefabCollection<NetInfo>.InitializePrefabs(newRoads.name, newRoads.m_prefabs, new string[] { });
                    PrefabCollection<NetInfo>.BindPrefabs();
                }


                // Modifiers ----------------------------------------------------------------------
                foreach (var modifier in Mod.NetInfoModifiers)
                {
                    try
                    {
                        modifier.ModifyExistingNetInfo();
                    }
                    catch (Exception ex)
                    {
                        Debug.Log(string.Format("NExt: Crashed-Network modifiers {0}", modifier));
                        Debug.Log("NExt: " + ex.Message);
                        Debug.Log("NExt: " + ex.ToString());
                    }
                }

                Debug.Log("NExt: Finished installing components");
            });
        }
コード例 #35
0
        private static bool ValidateNetworkPrerequisites(NetCollection newRoads)
        {
            var roadObject = GameObject.Find(Mod.ROAD_NETCOLLECTION);
            if (roadObject == null)
            {
                return false;
            }

            var netColl = FindObjectsOfType<NetCollection>();
            if (netColl == null || !netColl.Any())
            {
                return false;
            }

            var roadCollFound = false;
            foreach (var col in netColl)
            {
                if (col.name == Mod.ROAD_NETCOLLECTION)
                {
                    roadCollFound = true;
                }
            }

            if (!roadCollFound)
            {
                return false;
            }

            if (newRoads == null)
            {
                return false;
            }

            return true;
        }
コード例 #36
0
        public override void OnReleased()
        {
            base.OnReleased();

            if (_menuInstaller != null)
            {
                Object.Destroy(_menuInstaller);
                _menuInstaller = null;
            }

            if (_roadsInstaller != null)
            {
                Object.Destroy(_roadsInstaller);
                _roadsInstaller = null;
            }

            if (_roads != null)
            {
                Object.Destroy(_roads);
                _roads = null;
            }

            if (_props != null)
            {
                Object.Destroy(_props);
                _props = null;
            }

            if (_container != null)
            {
                Object.Destroy(_container);
                _container = null;
            }
        }
コード例 #37
0
        public override void OnReleased()
        {
            base.OnReleased();

            if (_isReleased)
            {
                return;
            }

            if (_initializer != null)
            {
                Object.Destroy(_initializer);
                _initializer = null;
            }

            if (_localizationInstaller != null)
            {
                Object.Destroy(_localizationInstaller);
                _localizationInstaller = null;
            }

            if (_assetsInstaller != null)
            {
                Object.Destroy(_assetsInstaller);
                _assetsInstaller = null;
            }

            if (_roadsInstaller != null)
            {
                Object.Destroy(_roadsInstaller);
                _roadsInstaller = null;
            }

            if (_menusInstaller != null)
            {
                Object.Destroy(_menusInstaller);
                _menusInstaller = null;
            }

            if (_newRoads != null)
            {
                Object.Destroy(_newRoads);
                _newRoads = null;
            }

            if (_container != null)
            {
                Object.Destroy(_container);
                _container = null;
            }

            _isReleased = true;
        }