private void OnActivate(EntityUid uid, SpawnArtifactComponent component, ArtifactActivatedEvent args) { if (component.Prototype == null) { return; } if (component.SpawnsCount >= component.MaxSpawns) { return; } // select spawn position near artifact var artifactCord = Transform(uid).Coordinates; var dx = _random.NextFloat(-component.Range, component.Range); var dy = _random.NextFloat(-component.Range, component.Range); var spawnCord = artifactCord.Offset(new Vector2(dx, dy)); // spawn entity var spawned = EntityManager.SpawnEntity(component.Prototype, spawnCord); component.SpawnsCount++; // if there is an user - try to put spawned item in their hands // doesn't work for spawners if (args.Activator != null && EntityManager.TryGetComponent(args.Activator.Value, out SharedHandsComponent? hands) && EntityManager.HasComponent <ItemComponent>(spawned)) { hands.TryPutInAnyHand(spawned); } }
private void OnActivate(EntityUid uid, SpawnArtifactComponent component, ArtifactActivatedEvent args) { if (component.Prototype == null) { return; } if (component.SpawnsCount >= component.MaxSpawns) { return; } // select spawn position near artifact var artifactCord = Transform(uid).Coordinates; var dx = _random.NextFloat(-component.Range, component.Range); var dy = _random.NextFloat(-component.Range, component.Range); var spawnCord = artifactCord.Offset(new Vector2(dx, dy)); // spawn entity var spawned = EntityManager.SpawnEntity(component.Prototype, spawnCord); component.SpawnsCount++; // if there is an user - try to put spawned item in their hands // doesn't work for spawners _handsSystem.PickupOrDrop(args.Activator, spawned); }
private void OnMapInit(EntityUid uid, SpawnArtifactComponent component, MapInitEvent args) { ChooseRandomPrototype(uid, component); }