public override void Update(bool eu) { Player ply = Sprinter; if (ply == null) { return; } if (room.game.cameras[0].room != room) { return; } // Spawn the player at the correct place if (timer == 0) { room.game.cameras[0].MoveCamera(4); room.game.cameras[0].followAbstractCreature = null; if (room.game.cameras[0].hud == null) { room.game.cameras[0].FireUpSinglePlayerHUD(ply); } for (int i = 0; i < 2; i++) { ply.bodyChunks[i].HardSetPosition(room.MiddleOfTile(68, 30)); } ply.graphicsModule?.Reset(); startController = new StartController(this); ply.controller = startController; ply.playerState.foodInStomach = 5; ply.eatCounter = 15; AbstractPhysicalObject shroom = new AbstractConsumable(room.world, AbstractPhysicalObject.AbstractObjectType.Mushroom, null, new WorldCoordinate(room.abstractRoom.index, 68, 30, 0), room.game.GetNewID(), -1, -1, null); room.abstractRoom.AddEntity(shroom); shroom.RealizeInRoom(); shroom.realizedObject.firstChunk.HardSetPosition(ply.mainBodyChunk.pos + new Vector2(-30f, 0f)); ply.SlugcatGrab(shroom.realizedObject, 0); room.game.cameras[0].hud.foodMeter.NewShowCount(ply.FoodInStomach); room.game.cameras[0].hud.foodMeter.visibleCounter = 0; room.game.cameras[0].hud.foodMeter.fade = 0f; room.game.cameras[0].hud.foodMeter.lastFade = 0f; } // End the cutscene if (timer == 180) { ply.controller = null; ply.room.game.cameras[0].followAbstractCreature = ply.abstractCreature; Destroy(); } timer++; }
// 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 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)); } } }