Esempio n. 1
0
 public void AIMapReady()
 {
     orig_AIMapReady();
     if (room.roomSettings.GetEffectAmount((RoomSettings.RoomEffect.Type)patch_RoomSettings.patch_RoomEffect.Type.LMSwarmers) > 0f)
     {
         bool         dark            = room.roomSettings.Palette == 24 || (room.roomSettings.fadePalette != null && room.roomSettings.fadePalette.palette == 24);
         IntVector2[] accessableTiles = room.aimap.CreatureSpecificAImap(StaticWorld.GetCreatureTemplate(CreatureTemplate.Type.Fly)).accessableTiles;
         int          num             = (int)((float)accessableTiles.Length * 0.05f * room.roomSettings.GetEffectAmount((RoomSettings.RoomEffect.Type)patch_RoomSettings.patch_RoomEffect.Type.LMSwarmers));
         System.Collections.Generic.List <IntVector2> list = new System.Collections.Generic.List <IntVector2>();
         for (int i = 0; i < num; i++)
         {
             list.Add(accessableTiles[UnityEngine.Random.Range(0, accessableTiles.Length)]);
         }
         LMOracleSwarmer.Behavior behavior = null;
         for (int j = 0; j < list.Count; j++)
         {
             LMOracleSwarmer LMOracleSwarmer = new LMOracleSwarmer(new AbstractPhysicalObject(room.world, (AbstractPhysicalObject.AbstractObjectType)patch_AbstractPhysicalObject.AbstractObjectType.LMOracleSwarmer, null, room.GetWorldCoordinate(list[j]), room.game.GetNewID()), room.world);
             LMOracleSwarmer.abstractPhysicalObject.destroyOnAbstraction = true;
             LMOracleSwarmer.firstChunk.HardSetPosition(room.MiddleOfTile(list[j]));
             LMOracleSwarmer.system           = this;
             LMOracleSwarmer.waitToFindOthers = j;
             LMOracleSwarmer.dark             = dark;
             if (behavior == null)
             {
                 behavior = LMOracleSwarmer.currentBehavior;
             }
             else
             {
                 LMOracleSwarmer.currentBehavior = behavior;
             }
             room.AddObject(LMOracleSwarmer);
             LMOracleSwarmer.NewRoom(room);
         }
     }
 }
Esempio n. 2
0
    private static void EstablishRelationship(CreatureTemplate.Type a, CreatureTemplate.Type b, CreatureTemplate.Relationship relationship)
    {
        if (relationship == new CreatureTemplate.Relationship(CreatureTemplate.Relationship.Type.Ignores, 0f))
        {
            relationship = new CreatureTemplate.Relationship(CreatureTemplate.Relationship.Type.Ignores, 0f);
        }
        CreatureTemplate creatureTemplate  = StaticWorld.GetCreatureTemplate(a);
        CreatureTemplate creatureTemplate2 = StaticWorld.GetCreatureTemplate(b);

        creatureTemplate.relationships[(int)creatureTemplate2.type] = relationship;
        foreach (CreatureTemplate creatureTemplate3 in StaticWorld.creatureTemplates)
        {
            if (creatureTemplate3.ancestor == creatureTemplate)
            {
                EstablishRelationship(creatureTemplate3.type, creatureTemplate2.type, relationship);
            }
        }
        foreach (CreatureTemplate creatureTemplate4 in StaticWorld.creatureTemplates)
        {
            if (creatureTemplate4.ancestor == creatureTemplate2)
            {
                EstablishRelationship(creatureTemplate.type, creatureTemplate4.type, relationship);
            }
        }
    }
        /// <summary>
        /// [Serverside] Creates a <see cref="PlayerShell"/> with a random username
        /// </summary>
        /// <param name="sender"></param>
        private void CreateShellServerside(System.Net.IPEndPoint sender)
        {
            if (ConnectedClients.Keys.Where(x => x.Equals(sender)).Count() == 0)
            {
                RWConsole.LogInfo("Creating PlayerInfo...");
                ConnectedClients[sender] = new PlayerInfo()
                {
                    ID = GetNewID(),
                };

                RWConsole.LogInfo("Creating abstract player...");
                AbstractCreature abstractPlayer = null;
                try {
                    abstractPlayer = new AbstractCreature
                                         (Game.world, StaticWorld.GetCreatureTemplate(CreatureTemplate.Type.Slugcat), null, new WorldCoordinate(), new EntityID());
                }
                catch (Exception e) {
                    if (Game == null)
                    {
                        RWConsole.LogError("Game is null!");
                    }
                    RWConsole.LogError(e);
                }
                RWConsole.LogInfo("Created abstract player.");

                RWConsole.LogInfo("Creating PlayerState...");
                PlayerState playerState = new PlayerState(abstractPlayer, 0, 1, false);
                abstractPlayer.state = playerState;
                RWConsole.LogInfo("Created PlayerState.");

                RWConsole.LogInfo("Realizing player...");
                try {
                    abstractPlayer?.Realize();
                    ConnectedClients[sender].Player = abstractPlayer?.realizedCreature as Player;
                    if (ConnectedClients[sender].Player == null)
                    {
                        RWConsole.LogError("Player is null!");
                    }
                }
                catch (Exception e) { RWConsole.LogError(e); }
                RWConsole.LogInfo("Realized player.");

                PlayerShell playerShell = new PlayerShell(ConnectedClients[sender]);
                Game.Players[0].Room.realizedRoom.AddObject(playerShell);
                RWConsole.LogInfo("Created PlayerInfo");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// [Clientside] Creates a <see cref="PlayerShell"/>
        /// </summary>
        /// <param name="username"></param>
        private void CreateShellClientside(string username)
        {
            if (!RemotePlayers.ContainsKey(username))
            {
                RWConsole.LogInfo($"Creating PlayerInfo for {username}...");
                RemotePlayers[username] = new PlayerInfo();

                RWConsole.LogInfo("Creating abstract player...");
                AbstractCreature abstractPlayer = null;
                try {
                    abstractPlayer = new AbstractCreature
                                         (Game.world, StaticWorld.GetCreatureTemplate(CreatureTemplate.Type.Slugcat), null, new WorldCoordinate(), new EntityID());
                }
                catch (Exception e) {
                    if (Game == null)
                    {
                        RWConsole.LogError("Game is null!");
                    }
                    RWConsole.LogError(e);
                }
                RWConsole.LogInfo("Created abstract player.");

                RWConsole.LogInfo("Creating PlayerState...");
                PlayerState playerState = new PlayerState(abstractPlayer, 0, 1, false);
                abstractPlayer.state = playerState;
                RWConsole.LogInfo("Created PlayerState.");

                RWConsole.LogInfo("Realizing player...");
                try {
                    abstractPlayer?.Realize();
                    RemotePlayers[username].Player = abstractPlayer?.realizedCreature as Player;
                    if (RemotePlayers[username].Player == null)
                    {
                        RWConsole.LogError("Player is null!");
                    }
                }
                catch (Exception e) { RWConsole.LogError(e); }
                RWConsole.LogInfo("Realized player.");

                PlayerShell playerShell = new PlayerShell(RemotePlayers[username]);
                Game.Players[0].Room.realizedRoom.AddObject(playerShell);
                RWConsole.LogInfo($"Created PlayerInfo for {username}");
            }
        }
Esempio n. 5
0
        static void WorldLoader_GeneratePopulation(On.WorldLoader.orig_GeneratePopulation orig, object self, bool fresh)
        {
            orig(self, fresh);

            OverseersPlugin.Logger_.LogInfo("infiltrated population generation!");

            if (self is WorldLoader wl)
            {
                int count = Random.Range(ConfigMenu.MinOverseers, ConfigMenu.MaxOverseers);
                for (int i = 0; i < count; i++)
                {
                    wl.world.offScreenDen.entitiesInDens.Add(new AbstractCreature(
                                                                 wl.world,
                                                                 StaticWorld.GetCreatureTemplate(CreatureTemplate.Type.Overseer),
                                                                 null,
                                                                 new WorldCoordinate(wl.world.offScreenDen.index, 1, 1, 0), // new WorldCoordinate(wl.world.offScreenDen.index, -1, -1, 0),
                                                                 wl.game.GetNewID()));
                }
                OverseersPlugin.Logger_.LogInfo($"added {count} overseers");
            }
        }
Esempio n. 6
0
        public static void SpawnArenaCreaturesVanilla(RainWorldGame game, ArenaSetup.GameTypeSetup.WildLifeSetting wildLifeSetting, ref List <AbstractCreature> availableCreatures, ref MultiplayerUnlocks unlocks, string[] array)
        {
            /*
             * Dictionary<string, int> tempDictionary = null;
             * Dictionary<string, int> tempDictionary2 = null;
             */
            float num = 1f;

            switch (wildLifeSetting)
            {
            case ArenaSetup.GameTypeSetup.WildLifeSetting.Off:
                return;

            case ArenaSetup.GameTypeSetup.WildLifeSetting.Low:
                num = 0.5f;
                break;

            case ArenaSetup.GameTypeSetup.WildLifeSetting.Medium:
                num = 1f;
                break;

            case ArenaSetup.GameTypeSetup.WildLifeSetting.High:
                num = 1.5f;
                break;
            }
            AbstractRoom abstractRoom = game.world.GetAbstractRoom(0);
            List <ArenaCreatureSpawner.Spawner>          list  = new List <ArenaCreatureSpawner.Spawner>();
            List <ArenaCreatureSpawner.CritterSpawnData> list2 = new List <ArenaCreatureSpawner.CritterSpawnData>();
            List <ArenaCreatureSpawner.CreatureGroup>    list3 = new List <ArenaCreatureSpawner.CreatureGroup>();
            List <ArenaCreatureSpawner.SpawnSymbol>      list4 = new List <ArenaCreatureSpawner.SpawnSymbol>();
            List <ArenaCreatureSpawner.DenGroup>         list5 = new List <ArenaCreatureSpawner.DenGroup>();
            float num2 = -1f;

            for (int i = 0; i < array.Length; i++)
            {
                if (array[i].Length > 2 && array[i].Substring(0, 2) != "//")
                {
                    string[] array2 = Regex.Split(array[i], " - ");
                    int      num3   = 1;
                    ArenaCreatureSpawner.Spawner spawner = null;
                    string text = array2[0];
                    int    num4;
                    if (text != null)
                    {
                        if (ArenaCreatureSpawnerHook.tempDictionary == null)
                        {
                            Dictionary <string, int> dictionary = new Dictionary <string, int>(5);
                            dictionary.Add("Creature", 0);
                            dictionary.Add("CreatureGroup", 1);
                            dictionary.Add("DenGroup", 2);
                            dictionary.Add("PlayersGlow", 3);
                            dictionary.Add("GoalAmount", 4);
                            ArenaCreatureSpawnerHook.tempDictionary = dictionary;
                        }
                        if (ArenaCreatureSpawnerHook.tempDictionary.TryGetValue(text, out num4))
                        {
                            switch (num4)
                            {
                            case 0:
                            {
                                CreatureTemplate.Type?type = WorldLoader.CreatureTypeFromString(array2[1]);
                                if (type != null)
                                {
                                    spawner = new ArenaCreatureSpawner.CritterSpawnData(type.Value);
                                }
                                else
                                {
                                    CustomWorldMod.Log("not rec. " + array2[1]);
                                }
                                break;
                            }

                            case 1:
                                spawner = new ArenaCreatureSpawner.CreatureGroup(array2[1]);
                                break;

                            case 2:
                            {
                                list5.Add(new ArenaCreatureSpawner.DenGroup(array2[1]));
                                string[] array3 = array2[2].Split(new char[]
                                    {
                                        ','
                                    });
                                for (int j = 0; j < array3.Length; j++)
                                {
                                    list5[list5.Count - 1].dens.Add(int.Parse(array3[j]));
                                }
                                break;
                            }

                            case 3:
                                game.GetArenaGameSession.playersGlowing = true;
                                break;

                            case 4:
                                num2 = float.Parse(array2[1]);
                                break;
                            }
                        }
                    }
                    if (spawner != null)
                    {
                        for (int k = 2; k < array2.Length; k++)
                        {
                            string[] array4 = Regex.Split(array2[k], ":");
                            text = array4[0];
                            if (text != null)
                            {
                                if (ArenaCreatureSpawnerHook.tempDictionary2 == null)
                                {
                                    Dictionary <string, int> dictionary = new Dictionary <string, int>(8);
                                    dictionary.Add("chance", 0);
                                    dictionary.Add("RARE", 1);
                                    dictionary.Add("group", 2);
                                    dictionary.Add("dens", 3);
                                    dictionary.Add("spawnDataString", 4);
                                    dictionary.Add("amount", 5);
                                    dictionary.Add("symbol", 6);
                                    dictionary.Add("invSymbol", 7);
                                    ArenaCreatureSpawnerHook.tempDictionary2 = dictionary;
                                }
                                if (ArenaCreatureSpawnerHook.tempDictionary2.TryGetValue(text, out num4))
                                {
                                    switch (num4)
                                    {
                                    case 0:
                                        spawner.spawnChance = float.Parse(array4[1]);
                                        break;

                                    case 1:
                                        if (spawner is ArenaCreatureSpawner.CritterSpawnData)
                                        {
                                            (spawner as ArenaCreatureSpawner.CritterSpawnData).rare = true;
                                        }
                                        break;

                                    case 2:
                                        spawner.groupString = array4[1];
                                        break;

                                    case 3:
                                        if (spawner is ArenaCreatureSpawner.CritterSpawnData)
                                        {
                                            bool flag = true;
                                            for (int l = 0; l < list5.Count; l++)
                                            {
                                                if (list5[l].name == array4[1])
                                                {
                                                    (spawner as ArenaCreatureSpawner.CritterSpawnData).dens = list5[l].dens;
                                                    flag = false;
                                                    break;
                                                }
                                            }
                                            if (flag)
                                            {
                                                string[] array5 = array4[1].Split(new char[]
                                                {
                                                    ','
                                                });
                                                for (int m = 0; m < array5.Length; m++)
                                                {
                                                    (spawner as ArenaCreatureSpawner.CritterSpawnData).dens.Add(int.Parse(array5[m]));
                                                }
                                            }
                                        }
                                        break;

                                    case 4:
                                        if (spawner is ArenaCreatureSpawner.CritterSpawnData)
                                        {
                                            (spawner as ArenaCreatureSpawner.CritterSpawnData).spawnDataString = array4[1];
                                        }
                                        break;

                                    case 5:
                                        if (spawner is ArenaCreatureSpawner.CritterSpawnData)
                                        {
                                            if (array4[1] == "players")
                                            {
                                                num3 = game.GetArenaGameSession.arenaSitting.players.Count;
                                            }
                                            else
                                            {
                                                string[] array5 = array4[1].Split(new char[]
                                                {
                                                    '-'
                                                });
                                                if (array5.Length == 1)
                                                {
                                                    num3 = int.Parse(array5[0]);
                                                }
                                                else
                                                {
                                                    num3 = UnityEngine.Random.Range(int.Parse(array5[0]), int.Parse(array5[1]) + 1);
                                                }
                                            }
                                        }
                                        break;

                                    case 6:
                                        ArenaCreatureSpawner.AddToSymbol(array4[1], false, ref list4);
                                        spawner.symbolString = array4[1];
                                        break;

                                    case 7:
                                        ArenaCreatureSpawner.AddToSymbol(array4[1], true, ref list4);
                                        spawner.invSymbolString = array4[1];
                                        break;
                                    }
                                }
                            }
                        }
                        if (num3 > 0)
                        {
                            if (spawner is ArenaCreatureSpawner.CreatureGroup)
                            {
                                list3.Add(spawner as ArenaCreatureSpawner.CreatureGroup);
                            }
                            else if (spawner is ArenaCreatureSpawner.CritterSpawnData)
                            {
                                list2.Add(spawner as ArenaCreatureSpawner.CritterSpawnData);
                            }
                            list.Add(spawner);
                            spawner.spawn = true;
                            for (int n = 1; n < num3; n++)
                            {
                                ArenaCreatureSpawner.CritterSpawnData critterSpawnData = new ArenaCreatureSpawner.CritterSpawnData((spawner as ArenaCreatureSpawner.CritterSpawnData).type);
                                critterSpawnData.dens            = (spawner as ArenaCreatureSpawner.CritterSpawnData).dens;
                                critterSpawnData.groupString     = (spawner as ArenaCreatureSpawner.CritterSpawnData).groupString;
                                critterSpawnData.symbolString    = (spawner as ArenaCreatureSpawner.CritterSpawnData).symbolString;
                                critterSpawnData.invSymbolString = (spawner as ArenaCreatureSpawner.CritterSpawnData).invSymbolString;
                                critterSpawnData.spawnChance     = (spawner as ArenaCreatureSpawner.CritterSpawnData).spawnChance;
                                critterSpawnData.spawnDataString = (spawner as ArenaCreatureSpawner.CritterSpawnData).spawnDataString;
                                critterSpawnData.rare            = (spawner as ArenaCreatureSpawner.CritterSpawnData).rare;
                                list2.Add(critterSpawnData);
                                list.Add(critterSpawnData);
                                critterSpawnData.spawn = true;
                            }
                        }
                    }
                }
            }
            for (int num5 = 0; num5 < list.Count; num5++)
            {
                if (list[num5].symbolString != null)
                {
                    for (int num6 = 0; num6 < list4.Count; num6++)
                    {
                        if (list[num5].symbolString.Substring(0, 1) == list4[num6].name)
                        {
                            list[num5].symbol = list4[num6];
                            list4[num6].connectedSpawners.Add(list[num5]);
                            break;
                        }
                    }
                }
                if (list[num5].invSymbolString != null)
                {
                    for (int num7 = 0; num7 < list4.Count; num7++)
                    {
                        if (list[num5].invSymbolString.Substring(0, 1) == list4[num7].name)
                        {
                            list[num5].invSymbol = list4[num7];
                            list4[num7].connectedSpawners.Add(list[num5]);
                            break;
                        }
                    }
                }
                if (list[num5].groupString != null)
                {
                    for (int num8 = 0; num8 < list3.Count; num8++)
                    {
                        if (list[num5].groupString == list3[num8].name)
                        {
                            list[num5].group = list3[num8];
                            list3[num8].connectedSpawners.Add(list[num5]);
                            break;
                        }
                    }
                }
            }
            Dictionary <CreatureTemplate.Type, bool> dictionary2 = new Dictionary <CreatureTemplate.Type, bool>();
            float num9 = 0f;
            List <CreatureTemplate.Type> list6 = new List <CreatureTemplate.Type>();
            List <CreatureTemplate.Type> list7 = new List <CreatureTemplate.Type>();

            for (int num10 = 0; num10 < list2.Count; num10++)
            {
                float num11 = Mathf.Clamp01(list2[num10].spawnChance);
                if (list2[num10].group != null)
                {
                    num11 *= Mathf.Clamp01(list2[num10].group.spawnChance);
                }
                if (list2[num10].symbol != null)
                {
                    num11 *= 1f / (float)list2[num10].symbol.possibleOutcomes.Count;
                }
                if (list2[num10].invSymbol != null)
                {
                    num11 *= 1f - 1f / (float)list2[num10].invSymbol.possibleOutcomes.Count;
                }
                if (unlocks.IsCreatureUnlockedForLevelSpawn(list2[num10].type))
                {
                    if (!list6.Contains(list2[num10].type))
                    {
                        list6.Add(list2[num10].type);
                    }
                }
                else
                {
                    if (!list7.Contains(list2[num10].type))
                    {
                        list7.Add(list2[num10].type);
                    }
                    CreatureTemplate.Type?type2 = unlocks.RecursiveFallBackCritter(new CreatureTemplate.Type?(list2[num10].type));
                    if (type2 != null)
                    {
                        CustomWorldMod.Log(list2[num10].type + " fall back to " + type2.Value);
                        list2[num10].type        = type2.Value;
                        list2[num10].spawnChance = Mathf.Clamp01(list2[num10].spawnChance) * 0.01f;
                        num11 *= 0.5f;
                    }
                    else
                    {
                        list2[num10].Disable();
                        num11 *= 0f;
                    }
                }
                num9 += num11;
            }
            float num12 = (float)list6.Count / (float)(list6.Count + list7.Count);

            CustomWorldMod.Log("percentCritTypesAllowed: " + num12);
            float num13 = Mathf.InverseLerp(0.7f, 0.3f, num12);

            if (num2 > 0f)
            {
                num2 *= Mathf.Lerp(Mathf.InverseLerp(0.15f, 0.75f, num12), 1f, 0.5f) * num;
            }
            CustomWorldMod.Log("diversify: " + num13);
            for (int num14 = 0; num14 < list3.Count; num14++)
            {
                if (UnityEngine.Random.value > list3[num14].spawnChance || !list3[num14].AnyConnectedSpawnersActive())
                {
                    list3[num14].Disable();
                }
            }
            for (int num15 = 0; num15 < list2.Count; num15++)
            {
                if (list2[num15].rare && UnityEngine.Random.value > Mathf.Pow(list2[num15].spawnChance, Custom.LerpMap(num12, 0.35f, 0.85f, 0.5f, 0.05f)))
                {
                    list2[num15].Disable();
                }
            }
            for (int num16 = 0; num16 < list4.Count; num16++)
            {
                list4[num16].decidedOutcome = list4[num16].possibleOutcomes[UnityEngine.Random.Range(0, list4[num16].possibleOutcomes.Count)];
                for (int num17 = 0; num17 < 10; num17++)
                {
                    if (list4[num16].AnyConnectedSpawnersActiveUnderCurrentRoll())
                    {
                        break;
                    }
                    list4[num16].decidedOutcome = list4[num16].possibleOutcomes[UnityEngine.Random.Range(0, list4[num16].possibleOutcomes.Count)];
                }
            }
            for (int num18 = 0; num18 < list.Count; num18++)
            {
                if (list[num18].group != null && !list[num18].group.spawn)
                {
                    list[num18].Disable();
                }
                else if (list[num18].symbol != null && list[num18].symbol.decidedOutcome != list[num18].symbolString.Substring(1, 1))
                {
                    list[num18].Disable();
                }
                else if (list[num18].invSymbol != null && list[num18].invSymbol.decidedOutcome == list[num18].invSymbolString.Substring(1, 1))
                {
                    list[num18].Disable();
                }
            }
            CustomWorldMod.Log(string.Concat(new object[]
            {
                "weight total pre rand: ",
                num9,
                " ga:",
                num2
            }));
            if (num2 > -1f)
            {
                num9 = Mathf.Lerp(num9, num2, 0.5f);
            }
            num9 *= num * Mathf.Lerp(0.8f, 1.2f, UnityEngine.Random.value);
            if (num2 > -1f)
            {
                num9 += Mathf.Lerp(-1.2f, 1.2f, Mathf.Pow(UnityEngine.Random.value, Custom.LerpMap(num9, num2 - 2f, num2 + 2f, 0.25f, 2f)));
            }
            else
            {
                num9 += Mathf.Lerp(-1.2f, 1.2f, Mathf.Pow(UnityEngine.Random.value, Custom.LerpMap(num9, 2f, 10f, 0.25f, 3f)));
            }
            CustomWorldMod.Log("weight total: " + num9);
            int num19 = Custom.IntClamp(Mathf.RoundToInt(num9), (int)wildLifeSetting, 25);

            CustomWorldMod.Log("creaturesToSpawn: " + num19);
            List <ArenaCreatureSpawner.CritterSpawnData> list8 = new List <ArenaCreatureSpawner.CritterSpawnData>();

            for (int num20 = 0; num20 < num19; num20++)
            {
                ArenaCreatureSpawner.CritterSpawnData critterSpawnData2 = ArenaCreatureSpawner.WeightedRandom(list2);
                if (critterSpawnData2 != null)
                {
                    critterSpawnData2.Disable();
                    list8.Add(critterSpawnData2);
                    if (num13 > 0f)
                    {
                        ArenaCreatureSpawner.Diversify(ref list2, critterSpawnData2.type, num13);
                    }
                }
            }
            CustomWorldMod.Log("-- ACTUALLY SPAWNING");
            for (int num21 = 0; num21 < list8.Count; num21++)
            {
                CustomWorldMod.Log(string.Concat(new object[]
                {
                    num21,
                    " ---- ",
                    list8[num21].type,
                    "(",
                    list8[num21].ID,
                    ")"
                }));
            }
            int[] array6 = new int[abstractRoom.nodes.Length];
            for (int num22 = 0; num22 < list8.Count; num22++)
            {
                ArenaCreatureSpawner.CritterSpawnData critterSpawnData3 = list8[num22];
                if (critterSpawnData3.dens.Count < 1 || critterSpawnData3.dens[0] == -1)
                {
                    AbstractCreature abstractCreature = ArenaCreatureSpawner.CreateAbstractCreature(game.world, critterSpawnData3.type, new WorldCoordinate(game.world.offScreenDen.index, -1, -1, 0), ref availableCreatures);
                    if (abstractCreature != null)
                    {
                        game.world.offScreenDen.AddEntity(abstractCreature);
                    }
                }
                else
                {
                    int num23 = int.MaxValue;
                    for (int num24 = 0; num24 < critterSpawnData3.dens.Count; num24++)
                    {
                        num23 = Math.Min(num23, array6[critterSpawnData3.dens[num24]]);
                    }
                    List <int> list9 = new List <int>();
                    for (int num25 = 0; num25 < critterSpawnData3.dens.Count; num25++)
                    {
                        if (array6[critterSpawnData3.dens[num25]] <= num23)
                        {
                            list9.Add(critterSpawnData3.dens[num25]);
                        }
                    }
                    int num26 = list9[UnityEngine.Random.Range(0, list9.Count)];
                    array6[num26]++;
                    if (StaticWorld.GetCreatureTemplate(critterSpawnData3.type).quantified)
                    {
                        abstractRoom.AddQuantifiedCreature(num26, critterSpawnData3.type, UnityEngine.Random.Range(7, 11));
                    }
                    else
                    {
                        AbstractCreature abstractCreature2 = ArenaCreatureSpawner.CreateAbstractCreature(game.world, critterSpawnData3.type, new WorldCoordinate(abstractRoom.index, -1, -1, num26), ref availableCreatures);
                        if (abstractCreature2 != null)
                        {
                            abstractRoom.MoveEntityToDen(abstractCreature2);
                            CreatureTemplate.Type type3 = abstractCreature2.creatureTemplate.type;
                            if (type3 == CreatureTemplate.Type.BigNeedleWorm)
                            {
                                for (int num27 = UnityEngine.Random.Range(0, 4); num27 >= 0; num27--)
                                {
                                    AbstractCreature ent = new AbstractCreature(game.world, StaticWorld.GetCreatureTemplate(CreatureTemplate.Type.SmallNeedleWorm), null, new WorldCoordinate(abstractRoom.index, -1, -1, num26), game.GetNewID());
                                    abstractRoom.MoveEntityToDen(ent);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 7
0
    // Token: 0x06000670 RID: 1648 RVA: 0x000356E4 File Offset: 0x000338E4
    public static Color ColorOfCreature(IconSymbol.IconSymbolData iconData)
    {
        switch (iconData.critType)
        {
        case CreatureTemplate.Type.Slugcat:
            return(PlayerGraphics.SlugcatColor(iconData.intData));

        case CreatureTemplate.Type.PinkLizard:
            return((StaticWorld.GetCreatureTemplate(iconData.critType).breedParameters as LizardBreedParams).standardColor);

        case CreatureTemplate.Type.GreenLizard:
            return((StaticWorld.GetCreatureTemplate(iconData.critType).breedParameters as LizardBreedParams).standardColor);

        case CreatureTemplate.Type.BlueLizard:
            return((StaticWorld.GetCreatureTemplate(iconData.critType).breedParameters as LizardBreedParams).standardColor);

        case CreatureTemplate.Type.YellowLizard:
        case CreatureTemplate.Type.Centipede:
        case CreatureTemplate.Type.SmallCentipede:
            return(new Color(1f, 0.6f, 0f));

        case CreatureTemplate.Type.WhiteLizard:
            return((StaticWorld.GetCreatureTemplate(iconData.critType).breedParameters as LizardBreedParams).standardColor);

        case CreatureTemplate.Type.RedLizard:
            return(new Color(0.9019608f, 0.05490196f, 0.05490196f));

        case (CreatureTemplate.Type)patch_CreatureTemplate.Type.GreyLizard:
            return(new Color(0.686f * 1.1f, 0.698f * 1.1f, 0.643f * 1.1f));

        case CreatureTemplate.Type.BlackLizard:
            return(new Color(0.368627459f, 0.368627459f, 0.435294122f));

        case (CreatureTemplate.Type)patch_CreatureTemplate.Type.SeaDrake:
            return(new Color(0.368627459f, 0.368627459f, 0.435294122f));

        case CreatureTemplate.Type.Salamander:
            return(new Color(0.933333337f, 0.78039217f, 0.894117653f));

        case CreatureTemplate.Type.CyanLizard:
        case CreatureTemplate.Type.Overseer:
            return(new Color(0f, 0.9098039f, 0.9019608f));

        case CreatureTemplate.Type.Leech:
        case CreatureTemplate.Type.SpitterSpider:
            return(new Color(0.68235296f, 0.156862751f, 0.117647059f));

        case CreatureTemplate.Type.SeaLeech:
        case CreatureTemplate.Type.TubeWorm:
            return(new Color(0.05f, 0.3f, 0.7f));

        case CreatureTemplate.Type.CicadaA:
            return(new Color(1f, 1f, 1f));

        case CreatureTemplate.Type.CicadaB:
            return(new Color(0.368627459f, 0.368627459f, 0.435294122f));

        case CreatureTemplate.Type.DaddyLongLegs:
            return(new Color(0f, 0f, 1f));

        case CreatureTemplate.Type.BrotherLongLegs:
            return(new Color(0.454901963f, 0.5254902f, 0.305882365f));

        case CreatureTemplate.Type.RedCentipede:
            return(new Color(0.9019608f, 0.05490196f, 0.05490196f));

        case CreatureTemplate.Type.Centiwing:
            return(new Color(0.05490196f, 0.698039234f, 0.235294119f));

        case CreatureTemplate.Type.VultureGrub:
            return(new Color(0.831372559f, 0.7921569f, 0.435294122f));

        case CreatureTemplate.Type.EggBug:
            return(new Color(0f, 1f, 0.470588237f));

        case CreatureTemplate.Type.SmallNeedleWorm:
        case CreatureTemplate.Type.BigNeedleWorm:
            return(new Color(1f, 0.596078455f, 0.596078455f));

        case CreatureTemplate.Type.Hazer:
            return(new Color(0.211764708f, 0.7921569f, 0.3882353f));
        }
        return(Menu.Menu.MenuRGB(Menu.Menu.MenuColors.MediumGrey));
    }
        private void SpawnEntity(SandboxEditor.PlacedIconData placedIconData)
        {
            IconSymbol.IconSymbolData data = placedIconData.data;
            WorldCoordinate           pos  = new WorldCoordinate(0, -1, -1, -1);

            pos.x = Mathf.RoundToInt(placedIconData.pos.x / 20f);
            pos.y = Mathf.RoundToInt(placedIconData.pos.y / 20f);
            EntityID entityID = (!base.GameTypeSetup.saveCreatures) ? this.game.GetNewID() : placedIconData.ID;

            if (data.itemType == AbstractPhysicalObject.AbstractObjectType.Creature)
            {
                AbstractCreature abstractCreature = null;
                if (base.GameTypeSetup.saveCreatures)
                {
                    for (int i = 0; i < this.arenaSitting.creatures.Count; i++)
                    {
                        if (this.arenaSitting.creatures[i].creatureTemplate.type == data.critType && this.arenaSitting.creatures[i].ID == entityID)
                        {
                            abstractCreature = this.arenaSitting.creatures[i];
                            this.arenaSitting.creatures.RemoveAt(i);
                            for (int j = 0; j < 2; j++)
                            {
                                abstractCreature.state.CycleTick();
                            }
                            string creatureString = SaveState.AbstractCreatureToString(abstractCreature);
                            abstractCreature     = SaveState.AbstractCreatureFromString(this.game.world, creatureString, false);
                            abstractCreature.pos = pos;
                            break;
                        }
                    }
                }
                if (abstractCreature == null)
                {
                    abstractCreature = new AbstractCreature(this.game.world, StaticWorld.GetCreatureTemplate(data.critType), null, pos, entityID);
                }
                CreatureTemplate.Type critType = data.critType;
                switch (critType)
                {
                case CreatureTemplate.Type.TentaclePlant:
                case CreatureTemplate.Type.PoleMimic:
                    abstractCreature.pos.x            = -1;
                    abstractCreature.pos.y            = -1;
                    abstractCreature.pos.abstractNode = data.intData;
                    this.game.world.GetAbstractRoom(0).entitiesInDens.Add(abstractCreature);
                    break;

                default:
                    switch (critType)
                    {
                    case CreatureTemplate.Type.Fly:
                    case CreatureTemplate.Type.Leech:
                    case CreatureTemplate.Type.SeaLeech:
                        for (int k = 0; k < 5; k++)
                        {
                            this.game.world.GetAbstractRoom(0).AddEntity(new AbstractCreature(this.game.world, StaticWorld.GetCreatureTemplate(data.critType), null, pos, entityID));
                        }
                        break;

                    default:
                        if (critType == CreatureTemplate.Type.Slugcat)
                        {
                            if (this.playerSpawnDens == null)
                            {
                                this.playerSpawnDens = new List <int>();
                            }
                            this.playerSpawnDens.Add(data.intData);
                        }
                        if (critType != CreatureTemplate.Type.Spider)
                        {
                            this.game.world.GetAbstractRoom(0).AddEntity(abstractCreature);
                        }
                        break;
                    }
                    break;

                case CreatureTemplate.Type.Centipede:
                {
                    float num = 0f;
                    if (data.intData == 2)
                    {
                        num = Mathf.Lerp(0.265f, 0.55f, Mathf.Pow(Custom.ClampedRandomVariation(0.5f, 0.5f, 0.7f), 1.2f));
                    }
                    else if (data.intData == 3)
                    {
                        num = Mathf.Lerp(0.7f, 1f, Mathf.Pow(UnityEngine.Random.value, 0.6f));
                    }
                    abstractCreature.spawnData = "{" + num.ToString() + "}";
                    this.game.world.GetAbstractRoom(0).AddEntity(abstractCreature);
                    break;
                }
                }
            }
            else
            {
                AbstractPhysicalObject.AbstractObjectType itemType = data.itemType;
                if (itemType != AbstractPhysicalObject.AbstractObjectType.Spear)
                {
                    if (itemType != AbstractPhysicalObject.AbstractObjectType.WaterNut)
                    {
                        if (itemType != AbstractPhysicalObject.AbstractObjectType.SporePlant)
                        {
                            if (itemType != AbstractPhysicalObject.AbstractObjectType.BubbleGrass)
                            {
                                if (AbstractConsumable.IsTypeConsumable(data.itemType))
                                {
                                    this.game.world.GetAbstractRoom(0).AddEntity(new AbstractConsumable(this.game.world, data.itemType, null, pos, entityID, -1, -1, null));
                                }
                                else
                                {
                                    this.game.world.GetAbstractRoom(0).AddEntity(new AbstractPhysicalObject(this.game.world, data.itemType, null, pos, entityID));
                                }
                            }
                            else
                            {
                                this.game.world.GetAbstractRoom(0).AddEntity(new BubbleGrass.AbstractBubbleGrass(this.game.world, null, pos, entityID, 1f, -1, -1, null));
                            }
                        }
                        else
                        {
                            this.game.world.GetAbstractRoom(0).AddEntity(new SporePlant.AbstractSporePlant(this.game.world, null, pos, entityID, -1, -1, null, false, true));
                        }
                    }
                    else
                    {
                        this.game.world.GetAbstractRoom(0).AddEntity(new WaterNut.AbstractWaterNut(this.game.world, null, pos, entityID, -1, -1, null, false));
                    }
                }
                else
                {
                    this.game.world.GetAbstractRoom(0).AddEntity(new AbstractSpear(this.game.world, null, pos, entityID, data.intData == 1));
                }
            }
        }
Esempio n. 9
0
        private static void SendNootArmy()
        {
            Game game = new Game();
            //Thank you Lee.
            AbstractRoom adjacentRoom;
            int          numOfNoodles = 20;

            Debug.Log("RELEASE THE NOOTS!");
            for (int i = 0; i < game.player.room.exitAndDenIndex.Length; i++)
            {
                if (game.player.room.WhichRoomDoesThisExitLeadTo(game.player.room.exitAndDenIndex[i]) != null)
                {
                    adjacentRoom = game.player.room.WhichRoomDoesThisExitLeadTo(game.player.room.exitAndDenIndex[i]);
                    WorldCoordinate node = adjacentRoom.RandomNodeInRoom();
                    if (adjacentRoom.realizedRoom == null)
                    {
                        adjacentRoom.RealizeRoom(game.player.room.world, game.player.room.world.game);
                    }
                    for (int c = 0; c < numOfNoodles; c++)
                    {
                        Debug.Log("Spawned a Noodle Fly");
                        AbstractCreature abstractNoodle = new AbstractCreature(game.player.room.world, StaticWorld.GetCreatureTemplate(CreatureTemplate.Type.BigNeedleWorm), null, node, adjacentRoom.world.game.GetNewID());
                        adjacentRoom.AddEntity(abstractNoodle);
                        abstractNoodle.RealizeInRoom();
                        abstractNoodle.state.socialMemory.GetOrInitiateRelationship(game.player.abstractCreature.ID).like     = -50f;
                        abstractNoodle.state.socialMemory.GetOrInitiateRelationship(game.player.abstractCreature.ID).tempLike = -50f;
                        abstractNoodle.abstractAI.InternalSetDestination(game.player.coord);
                    }
                    break;
                }
            }
        }
Esempio n. 10
0
    public static patch_CreatureTemplate AddTemplateData(patch_CreatureTemplate template)
    {
        List <TileConnectionResistance> list3 = new List <TileConnectionResistance>();
        List <TileTypeResistance>       list2 = new List <TileTypeResistance>();

        switch ((int)template.type)
        {
        default:
            break;

        case (int)patch_CreatureTemplate.Type.LightWorm:

            break;

        case (int)patch_CreatureTemplate.Type.CrossBat:

            break;

        case (int)patch_CreatureTemplate.Type.SeaDrake:
            list2.Clear();
            list3.Clear();
            template.baseDamageResistance    = 0.95f;
            template.baseStunResistance      = 0.9f;
            template.instantDeathDamageLimit = 1f;
            template.abstractedLaziness      = 100;
            template.AI                      = true;
            template.requireAImap            = true;
            template.canSwim                 = true;
            template.doPreBakedPathing       = false;
            template.offScreenSpeed          = 2f;
            template.bodySize                = 2f;
            template.preBakedPathingAncestor = new CreatureTemplate(CreatureTemplate.Type.Leech, null, list2, list3, new CreatureTemplate.Relationship(CreatureTemplate.Relationship.Type.Eats, 1f));;
            template.grasps                  = 1;
            template.stowFoodInDen           = true;
            template.visualRadius            = 300f;
            template.waterVision             = 1f;
            template.throughSurfaceVision    = 0.65f;
            template.movementBasedVision     = 0f;
            template.socialMemory            = true;
            template.communityInfluence      = 0f;
            template.communityID             = CreatureCommunities.CommunityID.None;
            template.waterRelationship       = CreatureTemplate.WaterRelationship.WaterOnly;
            template.meatPoints              = 6;
            break;

        case (int)patch_CreatureTemplate.Type.GreyLizard:
            list2.Clear();
            list3.Clear();
            list2.Add(new TileTypeResistance(AItile.Accessibility.OffScreen, 1f, PathCost.Legality.Allowed));
            list2.Add(new TileTypeResistance(AItile.Accessibility.Floor, 1f, PathCost.Legality.Allowed));
            list2.Add(new TileTypeResistance(AItile.Accessibility.Corridor, 1f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.Standard, 1f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.OpenDiagonal, 3f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.ReachOverGap, 3f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.ReachUp, 2f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.DoubleReachUp, 2f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.ReachDown, 2f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.SemiDiagonalReach, 2f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.DropToFloor, 20f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.DropToWater, 20f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.ShortCut, 1.5f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.NPCTransportation, 25f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.OffScreenMovement, 1f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.BetweenRooms, 10f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.LizardTurn, 10f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.Slope, 1.5f, PathCost.Legality.Allowed));
            CreatureTemplate creatureTemplate2 = new CreatureTemplate(CreatureTemplate.Type.LizardTemplate, null, list2, list3, new CreatureTemplate.Relationship(CreatureTemplate.Relationship.Type.Ignores, 0f));
            creatureTemplate2.offScreenSpeed     = 0.3f;
            creatureTemplate2.grasps             = 1;
            creatureTemplate2.virtualCreature    = true;
            creatureTemplate2.abstractedLaziness = 50;
            template.name                        = "GreyLizard";
            creatureTemplate2.AI                 = true;
            creatureTemplate2.requireAImap       = true;
            creatureTemplate2.bodySize           = 2f;
            creatureTemplate2.stowFoodInDen      = true;
            creatureTemplate2.shortcutSegments   = 3;
            creatureTemplate2.communityID        = CreatureCommunities.CommunityID.Lizards;
            creatureTemplate2.communityInfluence = 1f;
            creatureTemplate2.waterRelationship  = CreatureTemplate.WaterRelationship.AirAndSurface;
            creatureTemplate2.canSwim            = true;
            creatureTemplate2.socialMemory       = true;
            CreatureTemplate creatureTemplate3 = LizardBreeds.BreedTemplate(CreatureTemplate.Type.PinkLizard, creatureTemplate2, null, null, null);
            template      = (patch_CreatureTemplate)GreyLizardBreed.BreedTemplate(patch_CreatureTemplate.Type.GreyLizard, creatureTemplate2, creatureTemplate3, null, null);
            template.type = (CreatureTemplate.Type)patch_CreatureTemplate.Type.GreyLizard;
            break;

        case (int)patch_CreatureTemplate.Type.WalkerBeast:
            list2.Clear();
            list3.Clear();
            list2.Add(new TileTypeResistance(AItile.Accessibility.Air, 1f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.Standard, 1f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.OutsideRoom, 1f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.SideHighway, 100000f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.OffScreenMovement, 1f, PathCost.Legality.Allowed));
            list3.Add(new TileConnectionResistance(MovementConnection.MovementType.BetweenRooms, 10f, PathCost.Legality.Allowed));
            template = new patch_CreatureTemplate(CreatureTemplate.Type.Deer, null, list2, list3, new CreatureTemplate.Relationship(CreatureTemplate.Relationship.Type.Ignores, 0f));
            template.baseDamageResistance = 200f;
            template.baseStunResistance   = 8f;
            template.name = "WalkerBeast";
            template.type = (CreatureTemplate.Type)patch_CreatureTemplate.Type.WalkerBeast;
            template.abstractedLaziness = 10;
            template.AI                      = true;
            template.requireAImap            = true;
            template.doPreBakedPathing       = true;
            template.offScreenSpeed          = 1.5f;
            template.bodySize                = 2f;
            template.grasps                  = 1;
            template.stowFoodInDen           = false;
            template.visualRadius            = 1450f;
            template.waterVision             = 0.5f;
            template.throughSurfaceVision    = 0.65f;
            template.movementBasedVision     = 0f;
            template.hibernateOffScreen      = true;
            template.communityInfluence      = 0.85f;
            template.communityID             = CreatureCommunities.CommunityID.None;
            template.waterRelationship       = CreatureTemplate.WaterRelationship.AirOnly;
            template.preBakedPathingAncestor = StaticWorld.GetCreatureTemplate(CreatureTemplate.Type.Deer).preBakedPathingAncestor;
            break;
        }


        return(template);
    }
Esempio n. 11
0
    // Token: 0x060022D8 RID: 8920 RVA: 0x00212994 File Offset: 0x00210B94
    public override void Update(bool eu)
    {
        if (system != null && system.Frozen)
        {
            return;
        }
        base.Update(eu);
        if (!room.readyForAI || room.gravity * affectedByGravity > 0.5f)
        {
            return;
        }
        direction = travelDirection;
        switch (mode)
        {
        case MovementMode.Swarm:
            SwarmBehavior();
            if (onlySwarm > 0)
            {
                onlySwarm--;
            }
            else if (currentBehavior.suckle && UnityEngine.Random.value < 0.1f && system != null && system.mycelia.Count > 0)
            {
                Mycelium mycelium = system.mycelia[UnityEngine.Random.Range(0, system.mycelia.Count)];
                if (Custom.DistLess(firstChunk.pos, mycelium.Tip, 400f) && room.VisualContact(firstChunk.pos, mycelium.Tip))
                {
                    bool flag = false;
                    int  num  = 0;
                    while (num < otherSwarmers.Count && !flag)
                    {
                        if ((otherSwarmers[num] as LMOracleSwarmer).suckleMyc == mycelium)
                        {
                            flag = true;
                        }
                        num++;
                    }
                    if (!flag)
                    {
                        mode          = MovementMode.SuckleMycelia;
                        suckleMyc     = mycelium;
                        attachedToMyc = false;
                    }
                }
            }
            else if (room.aimap.getAItile(firstChunk.pos).terrainProximity < 7)
            {
                if (stuckListCounter > 0)
                {
                    stuckListCounter--;
                }
                else
                {
                    stuckList.Insert(0, firstChunk.pos);
                    if (stuckList.Count > 10)
                    {
                        stuckList.RemoveAt(stuckList.Count - 1);
                    }
                    stuckListCounter = 80;
                }
                if (UnityEngine.Random.value < 0.025f && stuckList.Count > 1 && Custom.DistLess(firstChunk.pos, stuckList[stuckList.Count - 1], 200f))
                {
                    System.Collections.Generic.List <int> list = new System.Collections.Generic.List <int>();
                    for (int i = 0; i < room.abstractRoom.connections.Length; i++)
                    {
                        if (room.aimap.ExitDistanceForCreature(room.GetTilePosition(firstChunk.pos), i, StaticWorld.GetCreatureTemplate(CreatureTemplate.Type.Fly)) > 0)
                        {
                            list.Add(i);
                        }
                    }
                    if (list.Count > 0)
                    {
                        mode     = MovementMode.FollowDijkstra;
                        dijkstra = list[UnityEngine.Random.Range(0, list.Count)];
                    }
                }
            }
            break;

        case MovementMode.SuckleMycelia:
            if (suckleMyc == null)
            {
                mode = MovementMode.Swarm;
            }
            else if (attachedToMyc)
            {
                direction = Custom.DirVec(firstChunk.pos, suckleMyc.Tip);
                float num2 = Vector2.Distance(firstChunk.pos, suckleMyc.Tip);
                firstChunk.vel -= (2f - num2) * direction * 0.15f;
                firstChunk.pos -= (2f - num2) * direction * 0.15f;
                suckleMyc.points[suckleMyc.points.GetLength(0) - 1, 0] += (2f - num2) * direction * 0.35f;
                suckleMyc.points[suckleMyc.points.GetLength(0) - 1, 2] += (2f - num2) * direction * 0.35f;
                travelDirection = new Vector2(0f, 0f);
                if (UnityEngine.Random.value < 0.05f)
                {
                    room.AddObject(new NeuronSpark((firstChunk.pos + suckleMyc.Tip) / 2f));
                }
                if (UnityEngine.Random.value < 0.0125f)
                {
                    suckleMyc = null;
                    onlySwarm = UnityEngine.Random.Range(40, 400);
                }
            }
            else
            {
                travelDirection = Custom.DirVec(firstChunk.pos, suckleMyc.Tip);
                if (Custom.DistLess(firstChunk.pos, suckleMyc.Tip, 5f))
                {
                    attachedToMyc = true;
                }
                else if (UnityEngine.Random.value < 0.05f && !room.VisualContact(firstChunk.pos, suckleMyc.Tip))
                {
                    suckleMyc = null;
                }
            }
            color = Vector2.Lerp(color, currentBehavior.color, 0.05f);
            break;

        case MovementMode.FollowDijkstra:
        {
            IntVector2 tilePosition = room.GetTilePosition(firstChunk.pos);
            int        num3         = -1;
            int        num4         = int.MaxValue;
            for (int j = 0; j < 4; j++)
            {
                if (!room.GetTile(tilePosition + Custom.fourDirections[j]).Solid)
                {
                    int num5 = room.aimap.ExitDistanceForCreature(tilePosition + Custom.fourDirections[j], dijkstra, StaticWorld.GetCreatureTemplate(CreatureTemplate.Type.Fly));
                    if (num5 > 0 && num5 < num4)
                    {
                        num3 = j;
                        num4 = num5;
                    }
                }
            }
            if (num3 > -1)
            {
                travelDirection += Custom.fourDirections[num3].ToVector2().normalized * 1.4f + Custom.RNV() * UnityEngine.Random.value * 0.5f;
            }
            else
            {
                mode = MovementMode.Swarm;
            }
            travelDirection.Normalize();
            int num6 = room.aimap.ExitDistanceForCreature(tilePosition, dijkstra, StaticWorld.GetCreatureTemplate(CreatureTemplate.Type.Fly));
            if ((UnityEngine.Random.value < 0.025f && num6 < 34) || num6 < 12 || dijkstra < 0 || UnityEngine.Random.value < 0.0025f || (room.aimap.getAItile(firstChunk.pos).terrainProximity >= 7 && UnityEngine.Random.value < 0.0166666675f))
            {
                mode = MovementMode.Swarm;
            }
            break;
        }
        }
        firstChunk.vel += travelDirection * 0.3f * (1f - room.gravity * affectedByGravity);
        firstChunk.vel *= Custom.LerpMap(firstChunk.vel.magnitude, 0.2f, 3f, 1f, 0.9f);
        if (currentBehavior.Dead)
        {
            Vector2 vector = currentBehavior.color;
            currentBehavior = new LMOracleSwarmer.Behavior(this);
            if (UnityEngine.Random.value > 0.25f)
            {
                currentBehavior.color = vector;
            }
        }
        else if (currentBehavior.leader == this)
        {
            currentBehavior.life -= currentBehavior.deathSpeed;
        }
        if (abstractPhysicalObject.destroyOnAbstraction && grabbedBy.Count > 0)
        {
            abstractPhysicalObject.destroyOnAbstraction = false;
        }
    }
Esempio n. 12
0
 public override void SpawnCreatures()
 {
     base.SpawnCreatures();
     if (this.PlayMode)
     {
         int num = -1;
         List <SandboxEditor.PlacedIconData> list = SandboxEditor.LoadConfiguration(ref num, this.arenaSitting.GetCurrentLevel);
         for (int i = 0; i < list.Count; i++)
         {
             this.SpawnEntity(list[i]);
         }
     }
     else
     {
         bool flag = false;
         if (this.arenaSitting.players.Count < 1)
         {
             flag = true;
             this.arenaSitting.players.Add(new ArenaSitting.ArenaPlayer(0));
         }
         for (int j = 0; j < this.arenaSitting.players.Count; j++)
         {
             AbstractCreature abstractCreature = new AbstractCreature(this.game.world, StaticWorld.GetCreatureTemplate(CreatureTemplate.Type.Overseer), null, new WorldCoordinate(0, 0, -50, 0), this.game.GetNewID());
             this.game.world.GetAbstractRoom(0).AddEntity(abstractCreature);
             abstractCreature.abstractAI.SetDestinationNoPathing(new WorldCoordinate(0, -1, -1, UnityEngine.Random.Range(0, this.game.world.GetAbstractRoom(0).nodes.Length)), true);
             (abstractCreature.abstractAI as OverseerAbstractAI).ownerIterator = 10 + this.arenaSitting.players[j].playerNumber;
         }
         if (flag)
         {
             this.arenaSitting.players.Clear();
         }
     }
 }
 private void GeneratePopulation(bool fresh)
 {
     Debug.Log(string.Concat(new object[]
     {
         "Generate population for : ",
         this.world.region.name,
         " FRESH: ",
         fresh
     }));
     if (this.world.game.setupValues.proceedLineages > 0)
     {
         for (int i = 0; i < this.spawners.Count; i++)
         {
             if (this.spawners[i] is World.Lineage)
             {
                 for (int j = 0; j < this.world.game.setupValues.proceedLineages; j++)
                 {
                     (this.spawners[i] as World.Lineage).ChanceToProgress(this.world);
                 }
             }
         }
     }
     //----------------------------------------Error start
     for (int k = 0; k < this.spawners.Count; k++)
     {
         if (this.spawners[k] is World.SimpleSpawner)
         {
             World.SimpleSpawner simpleSpawner = this.spawners[k] as World.SimpleSpawner;
             int num;
             if (fresh || StaticWorld.GetCreatureTemplate(simpleSpawner.creatureType).quantified || !StaticWorld.GetCreatureTemplate(simpleSpawner.creatureType).saveCreature)
             {
                 num = simpleSpawner.amount;
             }
             else
             {
                 num = this.HowManyOfThisCritterShouldRespawn(simpleSpawner.SpawnerID, simpleSpawner.amount);
             }
             if (num > 0)
             {
                 AbstractRoom abstractRoom = this.world.GetAbstractRoom(simpleSpawner.den);
                 if (abstractRoom != null && simpleSpawner.den.abstractNode >= 0 && simpleSpawner.den.abstractNode < abstractRoom.nodes.Length && (abstractRoom.nodes[simpleSpawner.den.abstractNode].type == AbstractRoomNode.Type.Den || abstractRoom.nodes[simpleSpawner.den.abstractNode].type == AbstractRoomNode.Type.GarbageHoles))
                 {
                     if (StaticWorld.GetCreatureTemplate(simpleSpawner.creatureType).quantified)
                     {
                         abstractRoom.AddQuantifiedCreature(simpleSpawner.den.abstractNode, simpleSpawner.creatureType, simpleSpawner.amount);
                     }
                     else
                     {
                         for (int l = 0; l < num; l++)
                         {
                             abstractRoom.MoveEntityToDen(new AbstractCreature(this.world, StaticWorld.GetCreatureTemplate(simpleSpawner.creatureType), null, simpleSpawner.den, this.world.game.GetNewID(simpleSpawner.SpawnerID))
                             {
                                 spawnData = simpleSpawner.spawnDataString
                             });
                         }
                     }
                 }
             }
         }
         else if (this.spawners[k] is World.Lineage)
         {
             World.Lineage lineage = this.spawners[k] as World.Lineage;
             bool          flag    = fresh || this.ShouldThisCritterRespawn(lineage.SpawnerID);
             if (flag)
             {
                 AbstractRoom          abstractRoom2 = this.world.GetAbstractRoom(lineage.den);
                 CreatureTemplate.Type?type          = lineage.CurrentType((this.game.session as StoryGameSession).saveState);
                 if (type == null)
                 {
                     lineage.ChanceToProgress(this.world);
                 }
                 else if (abstractRoom2 != null && lineage.den.abstractNode >= 0 && lineage.den.abstractNode < abstractRoom2.nodes.Length && (abstractRoom2.nodes[lineage.den.abstractNode].type == AbstractRoomNode.Type.Den || abstractRoom2.nodes[lineage.den.abstractNode].type == AbstractRoomNode.Type.GarbageHoles))
                 {
                     abstractRoom2.MoveEntityToDen(new AbstractCreature(this.world, StaticWorld.GetCreatureTemplate(type.Value), null, lineage.den, this.world.game.GetNewID(lineage.SpawnerID))
                     {
                         spawnData = lineage.CurrentSpawnData((this.game.session as StoryGameSession).saveState)
                     });
                 }
                 if (type == null)
                 {
                     (this.game.session as StoryGameSession).saveState.respawnCreatures.Add(lineage.SpawnerID);
                     Debug.Log("add NONE creature to respawns for lineage " + lineage.SpawnerID);
                 }
             }
         }
     }
     //--------------------Error end
     if (this.playerCharacter != 2 && !(this.game.session as StoryGameSession).saveState.guideOverseerDead && !(this.game.session as StoryGameSession).saveState.miscWorldSaveData.playerGuideState.angryWithPlayer && UnityEngine.Random.value < this.world.region.regionParams.playerGuideOverseerSpawnChance)
     {
         WorldCoordinate worldCoordinate = new WorldCoordinate(this.world.offScreenDen.index, -1, -1, 0);
         if (this.world.region.name == "SU")
         {
             worldCoordinate = new WorldCoordinate(this.world.GetAbstractRoom("SU_C04").index, 137, 17, 0);
         }
         AbstractCreature abstractCreature = new AbstractCreature(this.world, StaticWorld.GetCreatureTemplate(CreatureTemplate.Type.Overseer), null, worldCoordinate, new EntityID(-1, 5));
         if (this.world.GetAbstractRoom(worldCoordinate).offScreenDen)
         {
             this.world.GetAbstractRoom(worldCoordinate).entitiesInDens.Add(abstractCreature);
         }
         else
         {
             this.world.GetAbstractRoom(worldCoordinate).AddEntity(abstractCreature);
         }
         (abstractCreature.abstractAI as OverseerAbstractAI).SetAsPlayerGuide();
     }
     if (this.world.region.name == "UW" || UnityEngine.Random.value < this.world.region.regionParams.overseersSpawnChance * Mathf.InverseLerp(2f, 21f, (float)((this.game.session as StoryGameSession).saveState.cycleNumber + ((this.game.StoryCharacter != 2) ? 0 : 17))))
     {
         int num2 = UnityEngine.Random.Range(this.world.region.regionParams.overseersMin, this.world.region.regionParams.overseersMax);
         for (int m = 0; m < num2; m++)
         {
             this.world.offScreenDen.entitiesInDens.Add(new AbstractCreature(this.world, StaticWorld.GetCreatureTemplate(CreatureTemplate.Type.Overseer), null, new WorldCoordinate(this.world.offScreenDen.index, -1, -1, 0), this.game.GetNewID()));
         }
     }
 }
Esempio n. 14
0
        public void ReadPlayer(BinaryReader br, CSteamID sentPlayer)
        {
            if (!MonklandSteamManager.WorldManager.gameRunning)
            {
                return;
            }
            string roomName = br.ReadString();//Read Room Name

            if (!MonklandSteamManager.WorldManager.commonRooms.ContainsKey(roomName))
            {
                return;
            }
            AbstractRoom abstractRoom = patch_RainWorldGame.mainGame.world.GetAbstractRoom(roomName);

            if (abstractRoom == null || abstractRoom.realizedRoom == null)
            {
                return;
            }
            int             dist     = br.ReadInt32();                      // Read Disinguisher
            WorldCoordinate startPos = WorldCoordinateHandler.Read(ref br); // Read World Coordinate

            foreach (AbstractCreature cr in abstractRoom.creatures)
            {
                if (((cr as AbstractPhysicalObject) as patch_AbstractPhysicalObject).dist == dist && cr.realizedCreature != null)
                {
                    cr.realizedCreature = PlayerHandler.Read((cr.realizedCreature as Player), ref br);// Read Player
                    cr.pos.room         = abstractRoom.index;
                    return;
                }
            }
            startPos.room         = abstractRoom.index;
            startPos.abstractNode = -1;
            AbstractCreature abstractCreature = new AbstractCreature(patch_RainWorldGame.mainGame.world, StaticWorld.GetCreatureTemplate("Slugcat"), null, startPos, new EntityID(-1, 1));

            abstractCreature.state = new PlayerState(abstractCreature, 1, 0, false);
            ((abstractCreature as AbstractPhysicalObject) as patch_AbstractPhysicalObject).dist  = dist;
            ((abstractCreature as AbstractPhysicalObject) as patch_AbstractPhysicalObject).owner = sentPlayer.m_SteamID;
            abstractCreature.pos.room = abstractRoom.index;
            patch_RainWorldGame.mainGame.world.GetAbstractRoom(abstractCreature.pos.room).AddEntity(abstractCreature);
            abstractCreature.RealizeInRoom();
            abstractCreature.realizedCreature = PlayerHandler.Read((abstractCreature.realizedCreature as Player), ref br);// Read Player
            abstractCreature.pos.room         = abstractRoom.index;
        }
Esempio n. 15
0
        public void ctor_RainWorldGame(ProcessManager manager)
        {
            OriginalConstructor(manager);
            MonklandSteamManager.monklandUI = new UI.MonklandUI(Futile.stage);

            AbstractRoom thisRoom = this.world.GetAbstractRoom(this.overWorld.FIRSTROOM);


            if (thisRoom != null)
            {
                int num = thisRoom.index;

                foreach (AbstractCreature ac in session.Players)
                {
                    ac.Destroy();
                    this.world.GetAbstractRoom(ac.Room.index).RemoveEntity(ac);
                }

                foreach (AbstractPhysicalObject absPhys in thisRoom.entities)
                {
                    patch_AbstractPhysicalObject patch = absPhys as patch_AbstractPhysicalObject;

                    if (!MonklandSteamManager.ObjectManager.IsNetObject(patch))
                    {
                        patch.ownerID = NetworkGameManager.playerID;
                        MonklandSteamManager.ObjectManager.SendObjectCreation(patch);
                    }
                }

                session.Players.Clear();

                if (mainGame == null)
                {
                    mainGame = this;
                }

                ulong playerID = MonklandSteamManager.instance.allChannels[0].SendForcewaitPacket(0, (CSteamID)NetworkGameManager.managerID);

                Debug.Log("Player Count is " + session.Players.Count);

                if (this.IsStorySession)
                {
                    patch_AbstractCreature playerCreature = new AbstractCreature(this.world, StaticWorld.GetCreatureTemplate("Slugcat"), null, new WorldCoordinate(num, 15, 25, -1), new EntityID(-1, (int)playerID)) as patch_AbstractCreature;
                    playerCreature.state = new PlayerState(playerCreature, 0, this.GetStorySession.saveState.saveStateNumber, false);
                    this.world.GetAbstractRoom(playerCreature.pos.room).AddEntity(playerCreature);
                    if (this.session.Players.Count > 0)
                    {
                        this.session.Players.Insert(0, playerCreature);
                    }
                    else
                    {
                        this.session.Players.Add(playerCreature);
                    }

                    playerCreature.ownerIDNew = NetworkGameManager.playerID;
                    MonklandSteamManager.ObjectManager.SendObjectCreation(playerCreature);

                    MonklandUI.trackedPlayer = playerCreature;

                    this.cameras[0].followAbstractCreature = playerCreature;
                    this.roomRealizer.followCreature       = playerCreature;
                }
            }
        }