public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) { m_subsystemGameInfo = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true); m_subsystemSky = base.Project.FindSubsystem <SubsystemSky>(throwOnError: true); m_subsystemParticles = base.Project.FindSubsystem <SubsystemParticles>(throwOnError: true); m_subsystemAudio = base.Project.FindSubsystem <SubsystemAudio>(throwOnError: true); m_componentSpawn = base.Entity.FindComponent <ComponentSpawn>(throwOnError: true); m_componentBody = base.Entity.FindComponent <ComponentBody>(throwOnError: true); m_componentHealth = base.Entity.FindComponent <ComponentHealth>(throwOnError: true); m_dayEntityTemplateName = valuesDictionary.GetValue <string>("DayEntityTemplateName"); m_nightEntityTemplateName = valuesDictionary.GetValue <string>("NightEntityTemplateName"); float value = valuesDictionary.GetValue <float>("Probability"); if (!string.IsNullOrEmpty(m_dayEntityTemplateName)) { DatabaseManager.FindEntityValuesDictionary(m_dayEntityTemplateName, throwIfNotFound: true); } if (!string.IsNullOrEmpty(m_nightEntityTemplateName)) { DatabaseManager.FindEntityValuesDictionary(m_nightEntityTemplateName, throwIfNotFound: true); } m_timeToSwitch = s_random.Float(3f, 15f); IsEnabled = (s_random.Float(0f, 1f) < value); m_componentSpawn.Despawned += ComponentSpawn_Despawned; }
public void ComponentSpawn_Despawned(ComponentSpawn componentSpawn) { if (m_componentHealth.Health > 0f && !string.IsNullOrEmpty(m_spawnEntityTemplateName)) { Entity entity = DatabaseManager.CreateEntity(base.Project, m_spawnEntityTemplateName, throwIfNotFound: true); ComponentBody componentBody = entity.FindComponent <ComponentBody>(throwOnError: true); componentBody.Position = m_componentBody.Position; componentBody.Rotation = m_componentBody.Rotation; componentBody.Velocity = m_componentBody.Velocity; entity.FindComponent <ComponentSpawn>(throwOnError: true).SpawnDuration = 0.5f; base.Project.AddEntity(entity); } if (m_particleSystem != null) { m_particleSystem.Stopped = true; } }
public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) { m_subsystemGameInfo = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true); m_componentSpawn = base.Entity.FindComponent <ComponentSpawn>(); base.Load(valuesDictionary, idToEntityMap); }