// Helpers // Gets the configured regions special scavenger item. Affects init gearup and trader's specialty. private static bool TryGetSpecialScavItem(string regionName, out AbstractPhysicalObject.AbstractObjectType type) { type = default; foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks) { if (CustomWorldMod.installedPacks[keyValues.Key].regionConfig.TryGetValue(regionName, out CustomWorldStructs.RegionConfiguration config)) { if (config.scavTradeItem != null) { if (!Enum.IsDefined(typeof(AbstractPhysicalObject.AbstractObjectType), config.scavTradeItem)) { CustomWorldMod.Log($"Scavenger trade item misconfigured in {keyValues.Key}:{regionName}, got [{config.scavTradeItem}] which is not a valid AbstractObjectType", false, CustomWorldMod.DebugLevel.RELEASE); } else { CustomWorldMod.Log($"Found Scavenger trade item in {keyValues.Key}:{regionName}, got [{config.scavTradeItem}]", false, CustomWorldMod.DebugLevel.FULL); type = (AbstractPhysicalObject.AbstractObjectType)Enum.Parse(typeof(AbstractPhysicalObject.AbstractObjectType), config.scavTradeItem); return(true); } } } } return(false); }
// Hook me :) // Returns 0 on unknown // Score of items that scavs wouldn't normally hold, for the region they're trade specials. // Picked some values myself rather than making it a setting -- hen private static int GetScoreOfMissingItem(AbstractPhysicalObject.AbstractObjectType specialItem) { switch (specialItem) { // Commented out: already handled by the game, OR non-spawnable //case AbstractPhysicalObject.AbstractObjectType.Creature: //case AbstractPhysicalObject.AbstractObjectType.Rock: //case AbstractPhysicalObject.AbstractObjectType.Spear: //case AbstractPhysicalObject.AbstractObjectType.FlareBomb: //case AbstractPhysicalObject.AbstractObjectType.VultureMask: //case AbstractPhysicalObject.AbstractObjectType.PuffBall: case AbstractPhysicalObject.AbstractObjectType.DangleFruit: return(2); //case AbstractPhysicalObject.AbstractObjectType.Oracle: //case AbstractPhysicalObject.AbstractObjectType.PebblesPearl: case AbstractPhysicalObject.AbstractObjectType.SLOracleSwarmer: return(4); case AbstractPhysicalObject.AbstractObjectType.SSOracleSwarmer: return(3); //case AbstractPhysicalObject.AbstractObjectType.DataPearl: //case AbstractPhysicalObject.AbstractObjectType.SeedCob: //case AbstractPhysicalObject.AbstractObjectType.WaterNut: //case AbstractPhysicalObject.AbstractObjectType.JellyFish: //case AbstractPhysicalObject.AbstractObjectType.Lantern: //case AbstractPhysicalObject.AbstractObjectType.KarmaFlower: //case AbstractPhysicalObject.AbstractObjectType.Mushroom: //case AbstractPhysicalObject.AbstractObjectType.VoidSpawn: //case AbstractPhysicalObject.AbstractObjectType.FirecrackerPlant: case AbstractPhysicalObject.AbstractObjectType.SlimeMold: return(2); //case AbstractPhysicalObject.AbstractObjectType.FlyLure: //case AbstractPhysicalObject.AbstractObjectType.ScavengerBomb: //case AbstractPhysicalObject.AbstractObjectType.SporePlant: //case AbstractPhysicalObject.AbstractObjectType.AttachedBee: case AbstractPhysicalObject.AbstractObjectType.EggBugEgg: return(1); case AbstractPhysicalObject.AbstractObjectType.NeedleEgg: return(4); case AbstractPhysicalObject.AbstractObjectType.DartMaggot: return(2); case AbstractPhysicalObject.AbstractObjectType.BubbleGrass: return(3); case AbstractPhysicalObject.AbstractObjectType.NSHSwarmer: return(7); //case AbstractPhysicalObject.AbstractObjectType.OverseerCarcass: default: return(0); } }
static private AbstractPhysicalObject.AbstractObjectType AbstractPhysicalObjectTypeFromString(string objString) { string[] array = Regex.Split(objString, "<oA>"); try { AbstractPhysicalObject.AbstractObjectType abstractObjectType = Custom.ParseEnum <AbstractPhysicalObject.AbstractObjectType>(array[1]); return(abstractObjectType); } catch { return(0); } }
private static void CtorHK(On.AbstractPhysicalObject.orig_ctor orig, AbstractPhysicalObject self, World world, AbstractPhysicalObject.AbstractObjectType type, PhysicalObject realizedObject, WorldCoordinate pos, EntityID ID) { orig(self, world, type, realizedObject, pos, ID); //if (ID.number != -1 && ID.number != 5 && ID.number != 0 && self.ID.number != 1 && self.ID.number != 2 && self.ID.number == 3) //What? if (ID.number < -1 && ID.number > 5) { while (self.ID.number >= -1 && self.ID.number <= 15000) { self.ID.number = UnityEngine.Random.Range(int.MinValue, int.MaxValue); } } GetField(self); }
private static SLOracleBehaviorHasMark.MiscItemType MoonText(On.SLOracleBehaviorHasMark.orig_TypeOfMiscItem orig, SLOracleBehaviorHasMark moonConvo, PhysicalObject testItem) { AbstractPhysicalObject.AbstractObjectType itemType = testItem.abstractPhysicalObject.type; if (itemType == EnumExt_NewItems.Club) { return(EnumExt_NewItems.ClubDialogue); } if (itemType == EnumExt_NewItems.Bow) { return(EnumExt_NewItems.BowDialogue); } if (itemType == EnumExt_NewItems.Arrow) { Arrow arrow = testItem as Arrow; return(EnumExt_NewItems.ArrowDialogue); } return(orig(moonConvo, testItem)); }
// Hook me :) // Returns null on failure to instantiate // Instantiates an item of type inside ~~mind of scav~~ probably in offscreen den where scav is private static AbstractPhysicalObject InstantiateCustomScavItemAbstract(AbstractPhysicalObject.AbstractObjectType type, ScavengerAbstractAI self) { EntityID id = self.world.game.GetNewID(); switch (type) { // Commented out : safe default OR doesn't really work //case AbstractPhysicalObject.AbstractObjectType.Creature: //case AbstractPhysicalObject.AbstractObjectType.Rock: case AbstractPhysicalObject.AbstractObjectType.Spear: return(new AbstractSpear(self.world, null, self.parent.pos, id, self.IsSpearExplosive((!self.world.game.IsStorySession) ? 0 : (self.world.game.GetStorySession.saveState.cycleNumber + ((self.world.game.StoryCharacter != 2) ? 0 : 60))))); //case AbstractPhysicalObject.AbstractObjectType.FlareBomb: case AbstractPhysicalObject.AbstractObjectType.VultureMask: return(new VultureMask.AbstractVultureMask(self.world, null, self.parent.pos, id, id.RandomSeed, false)); //case AbstractPhysicalObject.AbstractObjectType.PuffBall: //case AbstractPhysicalObject.AbstractObjectType.DangleFruit: //case AbstractPhysicalObject.AbstractObjectType.Oracle: case AbstractPhysicalObject.AbstractObjectType.PebblesPearl: return(new PebblesPearl.AbstractPebblesPearl(self.world, null, self.parent.pos, id, -1, -1, null, id.RandomSeed % 3, id.RandomSeed % 3)); //case AbstractPhysicalObject.AbstractObjectType.SLOracleSwarmer: //case AbstractPhysicalObject.AbstractObjectType.SSOracleSwarmer: case AbstractPhysicalObject.AbstractObjectType.DataPearl: return(new DataPearl.AbstractDataPearl(self.world, AbstractPhysicalObject.AbstractObjectType.DataPearl, null, self.parent.pos, id, -1, -1, null, DataPearl.AbstractDataPearl.DataPearlType.Misc)); case AbstractPhysicalObject.AbstractObjectType.SeedCob: // Fails miserably return(new SeedCob.AbstractSeedCob(self.world, null, self.parent.pos, id, -1, -1, false, null)); case AbstractPhysicalObject.AbstractObjectType.WaterNut: return(new WaterNut.AbstractWaterNut(self.world, null, self.parent.pos, id, -1, -1, null, false)); //case AbstractPhysicalObject.AbstractObjectType.JellyFish: //case AbstractPhysicalObject.AbstractObjectType.Lantern: //case AbstractPhysicalObject.AbstractObjectType.KarmaFlower: //case AbstractPhysicalObject.AbstractObjectType.Mushroom: //case AbstractPhysicalObject.AbstractObjectType.VoidSpawn: //case AbstractPhysicalObject.AbstractObjectType.FirecrackerPlant: //case AbstractPhysicalObject.AbstractObjectType.SlimeMold: //case AbstractPhysicalObject.AbstractObjectType.FlyLure: //case AbstractPhysicalObject.AbstractObjectType.ScavengerBomb: case AbstractPhysicalObject.AbstractObjectType.SporePlant: return(new SporePlant.AbstractSporePlant(self.world, null, self.parent.pos, id, -1, -1, null, false, true)); //case AbstractPhysicalObject.AbstractObjectType.AttachedBee: case AbstractPhysicalObject.AbstractObjectType.EggBugEgg: int seed = UnityEngine.Random.seed; UnityEngine.Random.seed = id.RandomSeed; float hue = Mathf.Lerp(-0.15f, 0.1f, Custom.ClampedRandomVariation(0.5f, 0.5f, 2f)); UnityEngine.Random.seed = seed; return(new EggBugEgg.AbstractBugEgg(self.world, null, self.parent.pos, id, hue)); //case AbstractPhysicalObject.AbstractObjectType.NeedleEgg: //case AbstractPhysicalObject.AbstractObjectType.DartMaggot: case AbstractPhysicalObject.AbstractObjectType.BubbleGrass: return(new BubbleGrass.AbstractBubbleGrass(self.world, null, self.parent.pos, id, 1f, -1, -1, null)); //case AbstractPhysicalObject.AbstractObjectType.NSHSwarmer: case AbstractPhysicalObject.AbstractObjectType.OverseerCarcass: return(new OverseerCarcass.AbstractOverseerCarcass(self.world, null, self.parent.pos, id, new Color(0.1f, 0.1f, 0.1f), 0)); default: try { if (AbstractConsumable.IsTypeConsumable(type)) { return(new AbstractConsumable(self.parent.world, type, null, self.parent.pos, self.world.game.GetNewID(), -1, -1, null)); } else { return(new AbstractPhysicalObject(self.parent.world, type, null, self.parent.pos, self.world.game.GetNewID())); } } catch (Exception) { return(null); // This is nicer to manage if modders hook this method to spawn their own things. } } }
private string SpriteNameForItemPatch(On.ItemSymbol.orig_SpriteNameForItem orig, AbstractPhysicalObject.AbstractObjectType itemType, int intData) { if (itemType == EnumExt_NewItems.Club) { return("Symbol_Club"); } if (itemType == EnumExt_NewItems.Bow) { return("Symbol_Bow"); } if (itemType == EnumExt_NewItems.Arrow) { return(intData switch { 0 => "Symbol_Arrow", 1 => "Symbol_FireArrow", 2 => "Symbol_ExplosiveArrow", 3 => "Symbol_ElectricArrow", 4 => "Symbol_FlashArrow", _ => "Symbol_Arrow" });
public void ctor(World world, AbstractPhysicalObject.AbstractObjectType type, PhysicalObject realizedObject, WorldCoordinate pos, EntityID ID) { orig_ctor(world, type, realizedObject, pos, ID); }
public extern void orig_ctor(World world, AbstractPhysicalObject.AbstractObjectType type, PhysicalObject realizedObject, WorldCoordinate pos, EntityID ID);
patch_AbstractPhysicalObject(World world, AbstractPhysicalObject.AbstractObjectType type, PhysicalObject realizedObject, WorldCoordinate pos, EntityID ID) : base(world, type, realizedObject, pos, ID) { }
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)); } } }