public override IEnumerable <ISpawned> Spawn(Node worldNode, Vector3 location) { var chunk = SpawnHelpers.SpawnChunk(chunkType, location, worldNode, chunkScene, cloudSystem, random); yield return(chunk); }
public override IEnumerable <ISpawned> Spawn(Node worldNode, Vector3 location) { var chunk = SpawnHelpers.SpawnChunk(chunkType, location, worldNode, chunkScene, cloudSystem, random); yield return(chunk); ModLoader.ModInterface.TriggerOnChunkSpawned(chunk, true); }
public override List <ISpawned> Spawn(Node worldNode, Vector3 location) { var entities = new List <ISpawned>(); var chunk = SpawnHelpers.SpawnChunk(chunkType, location, worldNode, chunkScene, cloudSystem, random); entities.Add(chunk); return(entities); }
private void RespawnEntitiesFromSave(MicrobeStage savedMicrobeStage) { if (savedMicrobeStage.Player != null && !savedMicrobeStage.Player.Dead) { SpawnPlayer(); Player.ApplyPropertiesFromSave(savedMicrobeStage.Player); } if (savedGameEntities == null) { GD.PrintErr("Saved microbe stage contains no entities to load"); return; } var microbeScene = SpawnHelpers.LoadMicrobeScene(); var chunkScene = SpawnHelpers.LoadChunkScene(); var agentScene = SpawnHelpers.LoadAgentScene(); // This only should be used for things that get overridden anyway from the saved properties var random = new Random(); foreach (var thing in savedGameEntities) { // Skip the player as it was already loaded if (thing == savedMicrobeStage.Player) { continue; } switch (thing) { case Microbe casted: { var spawned = SpawnHelpers.SpawnMicrobe(casted.Species, Vector3.Zero, rootOfDynamicallySpawned, microbeScene, !casted.IsPlayerMicrobe, Clouds, CurrentGame); spawned.ApplyPropertiesFromSave(casted); break; } case FloatingChunk casted: { var spawned = SpawnHelpers.SpawnChunk(casted.CreateChunkConfigurationFromThis(), casted.Translation, rootOfDynamicallySpawned, chunkScene, Clouds, random); spawned.ApplyPropertiesFromSave(casted); break; } case AgentProjectile casted: { var spawned = SpawnHelpers.SpawnAgent(casted.Properties, casted.Amount, casted.TimeToLiveRemaining, casted.Translation, Vector3.Forward, rootOfDynamicallySpawned, agentScene, null); spawned.ApplyPropertiesFromSave(casted); // TODO: mapping from old microbe to recreated microbe to set emitter here break; } default: GD.PrintErr("Unknown entity type to load from save: ", thing.GetType()); break; } } // Clear this to make saving again work savedGameEntities = null; }