/// <summary> /// Do not use this directly. /// Size is fixed to 150f, 150f. /// </summary> /// <param name="pos">Position</param> /// <param name="type">Creature Type</param> public UIcreature(Vector2 pos, CreatureTemplate.Type type) : base(pos, new Vector2(150f, 150f)) { _inBox = true; if (!init) { return; } this.rect = new DyeableRect(menu, owner, pos + offset, size, true); this.subObjects.Add(this.rect); //owner.subObjects.Add(this.menuObj); this._type = type; cage = new FContainer(); this.myContainer.AddChild(cage); cage.SetPosition(new Vector2(75f, 20f)); fence = new FContainer(); this.myContainer.AddChild(fence); fence.SetPosition(new Vector2(75f, 20f)); fence.MoveToFront(); absTemplate = new OptionalCreatureTemplate(type); absCreature = new OptionalAbstractCreature(world, absTemplate); absCreature.state = new OptionalCreatureState(absCreature); }
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); } } }
private void ReadViolence(BinaryReader br, CSteamID sentPlayer) { // Message type // Damage type Creature.DamageType type = (Creature.DamageType)br.ReadByte(); // Lethal bool lethal = br.ReadBoolean(); // Source Template CreatureTemplate.Type sourceTemplate = (CreatureTemplate.Type)br.ReadByte(); // Source ID ulong sourceID = (ulong)br.ReadUInt64(); if (lethal) { string message = MonklandUI.BuildDeathMessage(sentPlayer, type, sourceTemplate, sourceID); Debug.Log(message); MonklandUI.AddMessage(message, 10); } MonklandSteamManager.Log($"[GameMNG] Reading Player Violence: Damage type {type}, Source Template {sourceTemplate}, Source ID {sourceID}"); }
public static int ReturnCreatureScoreValue(CreatureTemplate.Type crit) { switch (crit) { case CreatureTemplate.Type.PinkLizard: return(7); case CreatureTemplate.Type.GreenLizard: return(10); case CreatureTemplate.Type.BlueLizard: return(6); case CreatureTemplate.Type.YellowLizard: return(6); case CreatureTemplate.Type.WhiteLizard: return(8); case CreatureTemplate.Type.RedLizard: return(25); case CreatureTemplate.Type.BlackLizard: return(7); case CreatureTemplate.Type.Salamander: return(7); case CreatureTemplate.Type.CyanLizard: return(9); case CreatureTemplate.Type.Snail: return(1); case CreatureTemplate.Type.Vulture: return(15); case CreatureTemplate.Type.LanternMouse: return(2); case CreatureTemplate.Type.CicadaA: return(2); case CreatureTemplate.Type.CicadaB: return(2); case CreatureTemplate.Type.JetFish: return(4); case CreatureTemplate.Type.BigEel: return(25); case CreatureTemplate.Type.DaddyLongLegs: return(25); case CreatureTemplate.Type.BrotherLongLegs: return(14); case CreatureTemplate.Type.TentaclePlant: return(7); case CreatureTemplate.Type.PoleMimic: return(2); case CreatureTemplate.Type.MirosBird: return(16); case CreatureTemplate.Type.Centipede: return(7); case CreatureTemplate.Type.RedCentipede: return(19); case CreatureTemplate.Type.Centiwing: return(5); case CreatureTemplate.Type.SmallCentipede: return(4); case CreatureTemplate.Type.Scavenger: return(6); case CreatureTemplate.Type.EggBug: return(2); case CreatureTemplate.Type.BigSpider: return(4); case CreatureTemplate.Type.SpitterSpider: return(5); case CreatureTemplate.Type.BigNeedleWorm: return(5); case CreatureTemplate.Type.DropBug: return(5); case CreatureTemplate.Type.KingVulture: return(25); case CreatureTemplate.Type.Hazer: return(1); } return(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); } } } } } } }
public static string BuildDeathMessage(CSteamID deadPlayerID, Creature.DamageType damageType, CreatureTemplate.Type killerType, ulong killerID) { string deadPlayerName = SteamFriends.GetFriendPersonaName(deadPlayerID); string message = string.Empty; switch (damageType) { case Creature.DamageType.Blunt: message = $"{deadPlayerName} was killed using blunt force"; break; case Creature.DamageType.Stab: message = $"{deadPlayerName} was stabbed to death"; break; case Creature.DamageType.Bite: message = $"{deadPlayerName} was bitten to death"; break; case Creature.DamageType.Water: message = $"{deadPlayerName} drowned"; break; case Creature.DamageType.Explosion: message = $"{deadPlayerName} was blown up"; break; case Creature.DamageType.Electric: message = $"{deadPlayerName} was shocked to death"; break; } // Generic death message if (message.Equals(string.Empty)) { message = $"{deadPlayerName} was killed"; } string killerName = SteamFriends.GetFriendPersonaName((CSteamID)killerID); if (killerName.Equals(string.Empty)) { killerName = "Player"; } // TO DO -- When creatures are synced -- else if (killerType != CreatureTemplate.Type.Slugcat) { killerName = killerType.ToString(); } if (killerName != string.Empty && damageType != Creature.DamageType.Water && damageType != Creature.DamageType.Electric) { message += $" by {killerName}"; } Debug.Log($"Debug {message}"); return(message); }
public void ctor(CreatureTemplate.Type type, patch_CreatureTemplate ancestor, List <TileTypeResistance> tileResistances, List <TileConnectionResistance> connectionResistances, Relationship defaultRelationship) { this.roamInRoomChance = 0.1f; this.roamBetweenRoomsChance = 0.1f; this.waterVision = 0.4f; this.throughSurfaceVision = 0.8f; this.movementBasedVision = 0.2f; this.communityID = CreatureCommunities.CommunityID.All; this.communityInfluence = 0.5f; this.countsAsAKill = 2; this.lungCapacity = 520f; this.quickDeath = true; this.saveCreature = true; this.type = type; name = "???"; switch (type) { case CreatureTemplate.Type.StandardGroundCreature: name = "StandardGroundCreature"; break; case CreatureTemplate.Type.Slugcat: name = "Slugcat"; break; case CreatureTemplate.Type.LizardTemplate: name = "Lizard"; SetDoubleReachUpConnectionParams(AItile.Accessibility.Floor, AItile.Accessibility.Wall, AItile.Accessibility.Floor); break; case CreatureTemplate.Type.PinkLizard: name = "Pink Lizard"; break; case CreatureTemplate.Type.GreenLizard: name = "Green Lizard"; break; case CreatureTemplate.Type.BlueLizard: name = "Blue Lizard"; break; case CreatureTemplate.Type.YellowLizard: name = "Yellow Lizard"; break; case CreatureTemplate.Type.WhiteLizard: name = "White Lizard"; break; case CreatureTemplate.Type.RedLizard: name = "Red Lizard"; break; case CreatureTemplate.Type.BlackLizard: name = "Black Lizard"; break; case CreatureTemplate.Type.Salamander: name = "Salamander"; break; case CreatureTemplate.Type.CyanLizard: name = "Cyan Lizard"; break; case CreatureTemplate.Type.Fly: name = "Fly"; break; case CreatureTemplate.Type.Leech: name = "Leech"; break; case CreatureTemplate.Type.SeaLeech: name = "Sea Leech"; break; case CreatureTemplate.Type.Snail: name = "Snail"; break; case CreatureTemplate.Type.Vulture: name = "Vulture"; break; case CreatureTemplate.Type.GarbageWorm: name = "Garbage Worm"; break; case CreatureTemplate.Type.LanternMouse: name = "Lantern Mouse"; break; case CreatureTemplate.Type.CicadaA: name = "Cicada A"; break; case CreatureTemplate.Type.CicadaB: name = "Cicada B"; break; case CreatureTemplate.Type.Spider: name = "Spider"; break; case CreatureTemplate.Type.JetFish: name = "Jet Fish"; break; case (CreatureTemplate.Type)Type.SeaDrake: name = "SeaDrake"; break; case CreatureTemplate.Type.BigEel: name = "Big Eel"; break; case CreatureTemplate.Type.Deer: name = "Deer"; break; case (CreatureTemplate.Type)Type.WalkerBeast: name = "WalkerBeast"; break; case (CreatureTemplate.Type)Type.GreyLizard: name = "GreyLizard"; break; case CreatureTemplate.Type.TubeWorm: name = "Tube Worm"; SetDoubleReachUpConnectionParams(AItile.Accessibility.Floor, AItile.Accessibility.Wall, AItile.Accessibility.Floor); break; case CreatureTemplate.Type.DaddyLongLegs: name = "Daddy Long Legs"; break; case CreatureTemplate.Type.BrotherLongLegs: name = "Brother Long Legs"; break; case CreatureTemplate.Type.TentaclePlant: name = "Tentacle Plant"; break; case CreatureTemplate.Type.PoleMimic: name = "Pole Mimic"; break; case CreatureTemplate.Type.MirosBird: name = "Miros Bird"; break; case CreatureTemplate.Type.TempleGuard: name = "Temple Guard"; break; case CreatureTemplate.Type.Centipede: name = "Centipede"; break; case CreatureTemplate.Type.RedCentipede: name = "Red Centipede"; break; case CreatureTemplate.Type.Centiwing: name = "Centiwing"; break; case CreatureTemplate.Type.SmallCentipede: name = "Small Centipede"; break; case CreatureTemplate.Type.Scavenger: name = "Scavenger"; SetDoubleReachUpConnectionParams(AItile.Accessibility.Climb, AItile.Accessibility.Air, AItile.Accessibility.Climb); break; case CreatureTemplate.Type.Overseer: name = "Overseer"; break; case CreatureTemplate.Type.VultureGrub: name = "Vulture Grub"; break; case CreatureTemplate.Type.EggBug: name = "Egg Bug"; break; case CreatureTemplate.Type.BigSpider: name = "Big Spider"; break; case CreatureTemplate.Type.SpitterSpider: name = "Spitter Spider"; break; case CreatureTemplate.Type.SmallNeedleWorm: name = "Small Needle"; break; case CreatureTemplate.Type.BigNeedleWorm: name = "Big Needle"; break; case CreatureTemplate.Type.DropBug: name = "Drop Bug"; break; case CreatureTemplate.Type.KingVulture: name = "King Vulture"; break; case CreatureTemplate.Type.Hazer: name = "Hazer"; break; } relationships = new CreatureTemplate.Relationship[Enum.GetNames(typeof(CreatureTemplate.Type)).Length]; for (int i = 0; i < relationships.Length; i++) { relationships[i] = defaultRelationship; } virtualCreature = false; doPreBakedPathing = false; AI = false; requireAImap = false; quantified = false; canFly = false; grasps = 0; offScreenSpeed = 1f; abstractedLaziness = 1; smallCreature = false; mappedNodeTypes = new bool[Enum.GetNames(typeof(AbstractRoomNode.Type)).Length]; bodySize = 1f; scaryness = 1f; deliciousness = 1f; shortcutColor = new Color(1f, 1f, 1f); shortcutSegments = 1; waterRelationship = WaterRelationship.Amphibious; waterPathingResistance = 1f; canSwim = false; shortcutAversion = new PathCost(0f, PathCost.Legality.Allowed); NPCTravelAversion = new PathCost(100f, PathCost.Legality.Allowed); damageRestistances = new float[Enum.GetNames(typeof(Creature.DamageType)).Length, 2]; instantDeathDamageLimit = float.MaxValue; this.ancestor = ancestor; if (ancestor != null) { preBakedPathingAncestor = ancestor.preBakedPathingAncestor; virtualCreature = ancestor.virtualCreature; doPreBakedPathing = ancestor.doPreBakedPathing; AI = ancestor.AI; requireAImap = ancestor.requireAImap; quantified = ancestor.quantified; canFly = ancestor.canFly; grasps = ancestor.grasps; offScreenSpeed = ancestor.offScreenSpeed; abstractedLaziness = ancestor.abstractedLaziness; breedParameters = ancestor.breedParameters; stowFoodInDen = ancestor.stowFoodInDen; smallCreature = ancestor.smallCreature; roamInRoomChance = ancestor.roamInRoomChance; roamBetweenRoomsChance = ancestor.roamBetweenRoomsChance; visualRadius = ancestor.visualRadius; waterVision = ancestor.waterVision; throughSurfaceVision = ancestor.throughSurfaceVision; movementBasedVision = ancestor.movementBasedVision; dangerousToPlayer = ancestor.dangerousToPlayer; communityID = ancestor.communityID; communityInfluence = ancestor.communityInfluence; countsAsAKill = ancestor.countsAsAKill; quickDeath = ancestor.quickDeath; meatPoints = ancestor.meatPoints; wormGrassImmune = ancestor.wormGrassImmune; saveCreature = ancestor.saveCreature; hibernateOffScreen = ancestor.hibernateOffScreen; mappedNodeTypes = (bool[])ancestor.mappedNodeTypes.Clone(); bodySize = ancestor.bodySize; scaryness = ancestor.scaryness; deliciousness = ancestor.deliciousness; shortcutColor = ancestor.shortcutColor; shortcutSegments = ancestor.shortcutSegments; waterRelationship = ancestor.waterRelationship; waterPathingResistance = ancestor.waterPathingResistance; canSwim = ancestor.canSwim; socialMemory = ancestor.socialMemory; shortcutAversion = ancestor.shortcutAversion; NPCTravelAversion = ancestor.NPCTravelAversion; doubleReachUpConnectionParams = ancestor.doubleReachUpConnectionParams; relationships = (CreatureTemplate.Relationship[])ancestor.relationships.Clone(); baseDamageResistance = ancestor.baseDamageResistance; baseStunResistance = ancestor.baseStunResistance; instantDeathDamageLimit = ancestor.instantDeathDamageLimit; lungCapacity = ancestor.lungCapacity; } maxAccessibleTerrain = 0; pathingPreferencesTiles = new PathCost[Enum.GetNames(typeof(AItile.Accessibility)).Length]; pathingPreferencesConnections = new PathCost[Enum.GetNames(typeof(MovementConnection.MovementType)).Length]; if (ancestor == null) { for (int j = 0; j < pathingPreferencesTiles.Length; j++) { pathingPreferencesTiles[j] = new PathCost(10f * (float)j, PathCost.Legality.IllegalTile); } pathingPreferencesTiles[7] = new PathCost(100f, PathCost.Legality.SolidTile); for (int k = 0; k < pathingPreferencesConnections.Length; k++) { pathingPreferencesConnections[k] = new PathCost(100f, PathCost.Legality.IllegalConnection); } } else { pathingPreferencesTiles = (PathCost[])ancestor.pathingPreferencesTiles.Clone(); pathingPreferencesConnections = (PathCost[])ancestor.pathingPreferencesConnections.Clone(); } for (int l = 0; l < tileResistances.Count; l++) { pathingPreferencesTiles[(int)tileResistances[l].accessibility] = tileResistances[l].cost; if (tileResistances[l].cost.legality == PathCost.Legality.Allowed && maxAccessibleTerrain < (int)tileResistances[l].accessibility) { maxAccessibleTerrain = (int)tileResistances[l].accessibility; } } for (int m = 0; m <= maxAccessibleTerrain; m++) { if (pathingPreferencesTiles[m] > pathingPreferencesTiles[maxAccessibleTerrain]) { pathingPreferencesTiles[m] = pathingPreferencesTiles[maxAccessibleTerrain]; } } for (int n = 0; n < connectionResistances.Count; n++) { pathingPreferencesConnections[(int)connectionResistances[n].movementType] = connectionResistances[n].cost; } SetNodeType(AbstractRoomNode.Type.Exit, ConnectionResistance(MovementConnection.MovementType.ShortCut).Allowed); SetNodeType(AbstractRoomNode.Type.Den, ConnectionResistance(MovementConnection.MovementType.ShortCut).Allowed); SetNodeType(AbstractRoomNode.Type.SkyExit, ConnectionResistance(MovementConnection.MovementType.SkyHighway).Allowed); SetNodeType(AbstractRoomNode.Type.SeaExit, ConnectionResistance(MovementConnection.MovementType.SeaHighway).Allowed); SetNodeType(AbstractRoomNode.Type.SideExit, ConnectionResistance(MovementConnection.MovementType.SideHighway).Allowed); if (type == CreatureTemplate.Type.Scavenger) { SetNodeType(AbstractRoomNode.Type.Den, false); SetNodeType(AbstractRoomNode.Type.RegionTransportation, true); } if (type == CreatureTemplate.Type.Fly) { SetNodeType(AbstractRoomNode.Type.BatHive, true); } if (type == CreatureTemplate.Type.GarbageWorm) { for (int num = 0; num < mappedNodeTypes.Length; num++) { mappedNodeTypes[num] = false; } SetNodeType(AbstractRoomNode.Type.GarbageHoles, true); } }
public extern void orig_ctor(CreatureTemplate.Type type, patch_CreatureTemplate ancestor, List <TileTypeResistance> tileResistances, List <TileConnectionResistance> connectionResistances, Relationship defaultRelationship);
public patch_CreatureTemplate(CreatureTemplate.Type type, patch_CreatureTemplate ancestor, List <TileTypeResistance> tileResistances, List <TileConnectionResistance> connectionResistances, Relationship defaultRelationship) : base(type, ancestor, tileResistances, connectionResistances, defaultRelationship) { }
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)); } } }
public extern void orig_ctor(CreatureTemplate.Type template);
public bool TileAccessibleToCreature(IntVector2 pos, CreatureTemplate crit) { if (!crit.MovementLegalInRelationToWater(getAItile(pos).DeepWater, getAItile(pos).WaterSurface)) { return(false); } if (crit.PreBakedPathingIndex == -1) { return(false); } for (int i = 0; i < room.accessModifiers.Count; i++) { if (!room.accessModifiers[i].IsTileAccessible(pos, crit)) { return(false); } } CreatureTemplate.Type type = crit.type; switch (type) { case CreatureTemplate.Type.BigEel: if (getAItile(pos).terrainProximity < 4) { return(false); } break; case CreatureTemplate.Type.Deer: if (getAItile(pos).terrainProximity < 3) { return(false); } if (getAItile(pos).smoothedFloorAltitude > 17) { return(false); } break; case (CreatureTemplate.Type)patch_CreatureTemplate.Type.WalkerBeast: if (getAItile(pos).terrainProximity < 3) { return(false); } if (getAItile(pos).smoothedFloorAltitude > 17) { return(false); } break; default: if (type == CreatureTemplate.Type.Vulture || type == CreatureTemplate.Type.KingVulture) { if (getAItile(pos).terrainProximity < 2) { return(false); } } break; case CreatureTemplate.Type.DaddyLongLegs: case CreatureTemplate.Type.BrotherLongLegs: if (room.GetTile(pos).Terrain == Room.Tile.TerrainType.ShortcutEntrance) { return(true); } if (getAItile(pos).terrainProximity < 2 || getAItile(pos).terrainProximity > 11) { return(false); } break; case CreatureTemplate.Type.MirosBird: if (getAItile(pos).terrainProximity < 2) { return(false); } if (getAItile(pos).smoothedFloorAltitude > 2 && (float)(getAItile(pos).smoothedFloorAltitude + getAItile(pos).floorAltitude) > Custom.LerpMap((float)getAItile(pos).terrainProximity, 2f, 6f, 6f, 4f) * 2f) { return(false); } break; } return(crit.AccessibilityResistance(getAItile(pos).acc).Allowed || (crit.canSwim && getAItile(pos).acc != AItile.Accessibility.Solid && getAItile(pos).AnyWater)); }
public void ctor(World world, patch_CreatureTemplate creatureTemplate, patch_Creature realizedCreature, WorldCoordinate pos, EntityID ID) { orig_ctor(world, creatureTemplate, realizedCreature, pos, ID); CreatureTemplate.Type type = creatureTemplate.TopAncestor().type; if (creatureTemplate.AI) { type = creatureTemplate.type; switch (type) { case CreatureTemplate.Type.Scavenger: abstractAI = new ScavengerAbstractAI(world, this); goto IL_2F4; case CreatureTemplate.Type.Overseer: abstractAI = new OverseerAbstractAI(world, this); goto IL_2F4; default: switch (type) { case CreatureTemplate.Type.Vulture: break; default: if (type != CreatureTemplate.Type.MirosBird) { abstractAI = new AbstractCreatureAI(world, this); goto IL_2F4; } abstractAI = new MirosBirdAbstractAI(world, this); goto IL_2F4; case CreatureTemplate.Type.CicadaA: case CreatureTemplate.Type.CicadaB: abstractAI = new CicadaAbstractAI(world, this); goto IL_2F4; case CreatureTemplate.Type.BigEel: abstractAI = new BigEelAbstractAI(world, this); goto IL_2F4; case CreatureTemplate.Type.Deer: abstractAI = new DeerAbstractAI(world, this); goto IL_2F4; case (CreatureTemplate.Type)patch_CreatureTemplate.Type.WalkerBeast: abstractAI = new WalkerBeastAbstractAI(world, this); goto IL_2F4; } break; case CreatureTemplate.Type.SmallNeedleWorm: case CreatureTemplate.Type.BigNeedleWorm: abstractAI = new NeedleWormAbstractAI(world, this); goto IL_2F4; case CreatureTemplate.Type.DropBug: abstractAI = new DropBugAbstractAI(world, this); goto IL_2F4; case CreatureTemplate.Type.KingVulture: break; } abstractAI = new VultureAbstractAI(world, this); } IL_2F4: if (pos.abstractNode > -1 && pos.abstractNode < Room.nodes.Length && Room.nodes[pos.abstractNode].type == AbstractRoomNode.Type.Den && !pos.TileDefined) { if (Room.offScreenDen) { remainInDenCounter = 1; } else { remainInDenCounter = UnityEngine.Random.Range(100, 1000); } if (abstractAI != null) { abstractAI.denPosition = new WorldCoordinate?(pos); } spawnDen = pos; } if (creatureTemplate.type == CreatureTemplate.Type.TentaclePlant || creatureTemplate.type == CreatureTemplate.Type.PoleMimic) { remainInDenCounter = 0; } }