private void Spawn(RandomSpawnerComponent component) { if (component.RarePrototypes.Count > 0 && (component.RareChance == 1.0f || _robustRandom.Prob(component.RareChance))) { EntityManager.SpawnEntity(_robustRandom.Pick(component.RarePrototypes), Transform(component.Owner).Coordinates); return; } if (component.Chance != 1.0f && !_robustRandom.Prob(component.Chance)) { return; } if (component.Prototypes.Count == 0) { Logger.Warning($"Prototype list in RandomSpawnerComponent is empty! Entity: {component.Owner}"); return; } if (Deleted(component.Owner)) { return; } var offset = component.Offset; var xOffset = _robustRandom.NextFloat(-offset, offset); var yOffset = _robustRandom.NextFloat(-offset, offset); var coordinates = Transform(component.Owner).Coordinates.Offset(new Vector2(xOffset, yOffset)); EntityManager.SpawnEntity(_robustRandom.Pick(component.Prototypes), coordinates); }
private void OnRandSpawnMapInit(EntityUid uid, RandomSpawnerComponent component, MapInitEvent args) { Spawn(component); EntityManager.QueueDeleteEntity(uid); }