private void VaporizeSolids() { for (var i = _storage.ContainedEntities.Count - 1; i >= 0; i--) { var item = _storage.ContainedEntities.ElementAt(i); _storage.Remove(item); _entities.DeleteEntity(item); } }
public void PerformAction(EntityUid uid, EntityUid?userUid, IEntityManager entityManager) { if (!entityManager.TryGetComponent(uid, out ContainerManagerComponent? containerManager)) { Logger.Warning($"Computer entity {uid} did not have a container manager! Aborting build computer action."); return; } var containerSystem = entityManager.EntitySysManager.GetEntitySystem <ContainerSystem>(); if (!containerSystem.TryGetContainer(uid, Container, out var container, containerManager)) { Logger.Warning($"Computer entity {uid} did not have the specified '{Container}' container! Aborting build computer action."); return; } if (container.ContainedEntities.Count != 1) { Logger.Warning($"Computer entity {uid} did not have exactly one item in the specified '{Container}' container! Aborting build computer action."); } var board = container.ContainedEntities[0]; if (!entityManager.TryGetComponent(board, out ComputerBoardComponent? boardComponent)) { Logger.Warning($"Computer entity {uid} had an invalid entity in container \"{Container}\"! Aborting build computer action."); return; } container.Remove(board); var transform = entityManager.GetComponent <TransformComponent>(uid); var computer = entityManager.SpawnEntity(boardComponent.Prototype, transform.Coordinates); entityManager.GetComponent <TransformComponent>(computer).LocalRotation = transform.LocalRotation; var computerContainer = containerSystem.EnsureContainer <Container>(computer, Container); // In case it already existed and there are any entities inside the container, delete them. foreach (var ent in computerContainer.ContainedEntities.ToArray()) { computerContainer.ForceRemove(ent); entityManager.DeleteEntity(ent); } computerContainer.Insert(board); // We only add this container. If some construction needs to take other containers into account, fix this. entityManager.EntitySysManager.GetEntitySystem <ConstructionSystem>().AddContainer(computer, Container); // Delete the original entity. entityManager.DeleteEntity(uid); }
public void Cremate() { if (Open) { CloseStorage(); } if (_entities.TryGetComponent(Owner, out AppearanceComponent appearanceComponent)) { appearanceComponent.SetData(CrematoriumVisuals.Burning, true); } Cooking = true; SoundSystem.Play(Filter.Pvs(Owner), _crematingSound.GetSound(), Owner); _cremateCancelToken?.Cancel(); _cremateCancelToken = new CancellationTokenSource(); Owner.SpawnTimer(_burnMilis, () => { if (_entities.Deleted(Owner)) { return; } if (_entities.TryGetComponent(Owner, out appearanceComponent)) { appearanceComponent.SetData(CrematoriumVisuals.Burning, false); } Cooking = false; if (Contents.ContainedEntities.Count > 0) { for (var i = Contents.ContainedEntities.Count - 1; i >= 0; i--) { var item = Contents.ContainedEntities[i]; Contents.Remove(item); _entities.DeleteEntity(item); } var ash = _entities.SpawnEntity("Ash", _entities.GetComponent <TransformComponent>(Owner).Coordinates); Contents.Insert(ash); } TryOpenStorage(Owner); SoundSystem.Play(Filter.Pvs(Owner), _cremateFinishSound.GetSound(), Owner); }, _cremateCancelToken.Token); }
public void Update(float frameTime) { var movement = _speed * frameTime * (_up ? 1 : -1); _entMan.GetComponent <TransformComponent>(Owner).LocalPosition += (0, movement); _duration -= frameTime; _currentStep -= frameTime; if (_duration <= 0) { if (_rogue) { _entMan.RemoveComponent <PointingArrowComponent>(Owner); _entMan.AddComponent <RoguePointingArrowComponent>(Owner); return; } _entMan.DeleteEntity(Owner); return; } if (_currentStep <= 0) { _currentStep = _step; _up ^= true; } }
/// <summary> /// Fires a round of ammo out of the weapon. /// </summary> /// <param name="shooter">Entity that is operating the weapon, usually the player.</param> /// <param name="targetPos">Target position on the map to shoot at.</param> private void Fire(EntityUid shooter, Vector2 targetPos) { if (ShotsLeft == 0) { SoundSystem.Play(Filter.Broadcast(), SoundEmpty.GetSound(), Owner); return; } var ammo = PeekAmmo(); if (TakeProjectile(Entities.GetComponent <TransformComponent>(shooter).Coordinates) is not { Valid: true } projectile) { SoundSystem.Play(Filter.Broadcast(), SoundEmpty.GetSound(), Owner); return; } // At this point firing is confirmed var direction = (targetPos - Entities.GetComponent <TransformComponent>(shooter).WorldPosition).ToAngle(); var angle = GetRecoilAngle(direction); // This should really be client-side but for now we'll just leave it here if (Entities.HasComponent <CameraRecoilComponent>(shooter)) { var kick = -angle.ToVec() * 0.15f; EntitySystem.Get <CameraRecoilSystem>().KickCamera(shooter, kick); } // This section probably needs tweaking so there can be caseless hitscan etc. if (Entities.TryGetComponent(projectile, out HitscanComponent? hitscan)) { FireHitscan(shooter, hitscan, angle); } else if (Entities.HasComponent <ProjectileComponent>(projectile) && Entities.TryGetComponent(ammo, out AmmoComponent? ammoComponent)) { FireProjectiles(shooter, projectile, ammoComponent.ProjectilesFired, ammoComponent.EvenSpreadAngle, angle, ammoComponent.Velocity, ammo.Value); if (CanMuzzleFlash) { EntitySystem.Get <GunSystem>().MuzzleFlash(Owner, ammoComponent, angle); } if (ammoComponent.Caseless) { Entities.DeleteEntity(ammo.Value); } } else { // Invalid types throw new InvalidOperationException(); } SoundSystem.Play(Filter.Broadcast(), SoundGunshot.GetSound(), Owner); _lastFire = _gameTiming.CurTime; }
public void Fire(ParticleAcceleratorPowerState state, Angle angle, EntityUid firer) { State = state; if (!_entMan.TryGetComponent <PhysicsComponent?>(Owner, out var physicsComponent)) { Logger.Error("ParticleProjectile tried firing, but it was spawned without a CollidableComponent"); return; } physicsComponent.BodyStatus = BodyStatus.InAir; if (!_entMan.TryGetComponent <ProjectileComponent?>(Owner, out var projectileComponent)) { Logger.Error("ParticleProjectile tried firing, but it was spawned without a ProjectileComponent"); return; } projectileComponent.IgnoreEntity(firer); if (!_entMan.TryGetComponent <SinguloFoodComponent?>(Owner, out var singuloFoodComponent)) { Logger.Error("ParticleProjectile tried firing, but it was spawned without a SinguloFoodComponent"); return; } var multiplier = State switch { ParticleAcceleratorPowerState.Standby => 0, ParticleAcceleratorPowerState.Level0 => 1, ParticleAcceleratorPowerState.Level1 => 3, ParticleAcceleratorPowerState.Level2 => 6, ParticleAcceleratorPowerState.Level3 => 10, _ => 0 }; singuloFoodComponent.Energy = 10 * multiplier; var suffix = state switch { ParticleAcceleratorPowerState.Level0 => "0", ParticleAcceleratorPowerState.Level1 => "1", ParticleAcceleratorPowerState.Level2 => "2", ParticleAcceleratorPowerState.Level3 => "3", _ => "0" }; if (!_entMan.TryGetComponent <SpriteComponent?>(Owner, out var spriteComponent)) { Logger.Error("ParticleProjectile tried firing, but it was spawned without a SpriteComponent"); return; } spriteComponent.LayerSetState(0, $"particle{suffix}"); physicsComponent .LinearVelocity = angle.ToWorldVec() * 20f; _entMan.GetComponent <TransformComponent>(Owner).LocalRotation = angle; Timer.Spawn(3000, () => _entMan.DeleteEntity(Owner)); } } }
protected override void OnKill() { if (_entMan.Deleted(Owner)) { return; } _entMan.DeleteEntity(Owner); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); _preferencesManager.OnServerDataLoaded -= UpdateUI; if (!disposing) return; if (_previewDummy != null) _entityManager.DeleteEntity(_previewDummy.Value); _previewDummy = default; }
public void FireEffects(EntityUid user, float distance, Angle angle, EntityUid?hitEntity = null) { var effectSystem = EntitySystem.Get <EffectSystem>(); _startTime = _gameTiming.CurTime; _deathTime = _startTime + TimeSpan.FromSeconds(1); var mapManager = IoCManager.Resolve <IMapManager>(); // We'll get the effects relative to the grid / map of the firer var gridOrMap = _entMan.GetComponent <TransformComponent>(user).GridID == GridId.Invalid ? mapManager.GetMapEntityId(_entMan.GetComponent <TransformComponent>(user).MapID) : mapManager.GetGrid(_entMan.GetComponent <TransformComponent>(user).GridID).GridEntityId; var parentXform = _entMan.GetComponent <TransformComponent>(gridOrMap); var localCoordinates = new EntityCoordinates(gridOrMap, parentXform.InvWorldMatrix.Transform(_entMan.GetComponent <TransformComponent>(user).WorldPosition)); var localAngle = angle - parentXform.WorldRotation; var afterEffect = AfterEffects(localCoordinates, localAngle, distance, 1.0f); if (afterEffect != null) { effectSystem.CreateParticle(afterEffect); } // if we're too close we'll stop the impact and muzzle / impact sprites from clipping if (distance > 1.0f) { var impactEffect = ImpactFlash(distance, localAngle); if (impactEffect != null) { effectSystem.CreateParticle(impactEffect); } var muzzleEffect = MuzzleFlash(localCoordinates, localAngle); if (muzzleEffect != null) { effectSystem.CreateParticle(muzzleEffect); } } if (hitEntity != null && _soundHitWall != null) { // TODO: No wall component so ? var offset = localAngle.ToVec().Normalized / 2; var coordinates = localCoordinates.Offset(offset); SoundSystem.Play(Filter.Pvs(coordinates), _soundHitWall.GetSound(), coordinates); } Owner.SpawnTimer((int)_deathTime.TotalMilliseconds, () => { if (!_entMan.Deleted(Owner)) { _entMan.DeleteEntity(Owner); } }); }
protected override void Shutdown() { base.Shutdown(); // _overlayEntity is non-nullable as it is set on startup. // Should also never be default but might as well check. if (_overlayEntity.Valid) { _entMan.DeleteEntity(_overlayEntity); } }
protected override void Shutdown() { base.Shutdown(); EntityUid tempQualifier = _overlayEntity; if (tempQualifier != null) { _entMan.DeleteEntity(tempQualifier); } }
/// <summary> /// Gets called by an AreaEffectInceptionComponent. "Clones" Owner into the four directions and copies the /// solution into each of them. /// </summary> public void Spread() { if (_entities.GetComponent <MetaDataComponent>(Owner).EntityPrototype == null) { Logger.Error("AreaEffectComponent needs its owner to be spawned by a prototype."); return; } void SpreadToDir(Direction dir) { var grid = MapManager.GetGrid(_entities.GetComponent <TransformComponent>(Owner).GridID); var coords = _entities.GetComponent <TransformComponent>(Owner).Coordinates; foreach (var neighbor in grid.GetInDir(coords, dir)) { if (_entities.TryGetComponent(neighbor, out SolutionAreaEffectComponent? comp) && comp.Inception == Inception) { return; } if (_entities.TryGetComponent(neighbor, out AirtightComponent? airtight) && airtight.AirBlocked) { return; } } var newEffect = _entities.SpawnEntity( _entities.GetComponent <MetaDataComponent>(Owner).EntityPrototype?.ID, grid.DirectionToGrid(coords, dir)); if (!_entities.TryGetComponent(newEffect, out SolutionAreaEffectComponent? effectComponent)) { _entities.DeleteEntity(newEffect); return; } if (EntitySystem.Get <SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)) { effectComponent.TryAddSolution(solution.Clone()); } effectComponent.Amount = Amount - 1; Inception?.Add(effectComponent); } SpreadToDir(Direction.North); SpreadToDir(Direction.East); SpreadToDir(Direction.South); SpreadToDir(Direction.West); }
public void Fire(ParticleAcceleratorPowerState state, Angle angle, EntityUid firer) { State = state; if (!_entMan.TryGetComponent <PhysicsComponent?>(Owner, out var physicsComponent)) { Logger.Error("ParticleProjectile tried firing, but it was spawned without a CollidableComponent"); return; } physicsComponent.BodyStatus = BodyStatus.InAir; if (!_entMan.TryGetComponent <ProjectileComponent?>(Owner, out var projectileComponent)) { Logger.Error("ParticleProjectile tried firing, but it was spawned without a ProjectileComponent"); return; } _entMan.EntitySysManager.GetEntitySystem <ProjectileSystem>().SetShooter(projectileComponent, firer); if (!_entMan.TryGetComponent <SinguloFoodComponent?>(Owner, out var singuloFoodComponent)) { Logger.Error("ParticleProjectile tried firing, but it was spawned without a SinguloFoodComponent"); return; } var multiplier = State switch { ParticleAcceleratorPowerState.Standby => 0, ParticleAcceleratorPowerState.Level0 => 1, ParticleAcceleratorPowerState.Level1 => 3, ParticleAcceleratorPowerState.Level2 => 6, ParticleAcceleratorPowerState.Level3 => 10, _ => 0 }; singuloFoodComponent.Energy = 10 * multiplier; if (_entMan.TryGetComponent(Owner, out AppearanceComponent? appearance)) { appearance.SetData(ParticleAcceleratorVisuals.VisualState, state); } physicsComponent.LinearVelocity = angle.ToWorldVec() * 20f; _entMan.GetComponent <TransformComponent>(Owner).LocalRotation = angle; Timer.Spawn(3000, () => _entMan.DeleteEntity(Owner)); } }
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { if (_cableDroppedOnCutPrototype == null) return false; if (!await EntitySystem.Get<ToolSystem>().UseTool(eventArgs.Using, eventArgs.User, Owner, 0f, 0.25f, _cuttingQuality)) return false; if (EntitySystem.Get<ElectrocutionSystem>().TryDoElectrifiedAct(Owner, eventArgs.User)) return false; _entMan.DeleteEntity(Owner); var droppedEnt = _entMan.SpawnEntity(_cableDroppedOnCutPrototype, eventArgs.ClickLocation); // TODO: Literally just use a prototype that has a single thing in the stack, it's not that complicated... if (_entMan.TryGetComponent<StackComponent?>(droppedEnt, out var stack)) EntitySystem.Get<StackSystem>().SetCount(droppedEnt, 1, stack); return true; }
bool IUse.UseEntity(UseEntityEventArgs eventArgs) { if (_countDown || (_grenadesContainer.ContainedEntities.Count + _unspawnedCount) <= 0) { return(false); } Owner.SpawnTimer((int)(_delay * 1000), () => { if (_entMan.Deleted(Owner)) { return; } _countDown = true; var random = IoCManager.Resolve <IRobustRandom>(); var delay = 20; var grenadesInserted = _grenadesContainer.ContainedEntities.Count + _unspawnedCount; var thrownCount = 0; var segmentAngle = 360 / grenadesInserted; while (TryGetGrenade(out var grenade)) { var angleMin = segmentAngle * thrownCount; var angleMax = segmentAngle * (thrownCount + 1); var angle = Angle.FromDegrees(random.Next(angleMin, angleMax)); // var distance = random.NextFloat() * _throwDistance; delay += random.Next(550, 900); thrownCount++; // TODO: Suss out throw strength grenade.TryThrow(angle.ToVec().Normalized *_throwDistance); grenade.SpawnTimer(delay, () => { if ((!_entMan.EntityExists(grenade) ? EntityLifeStage.Deleted : _entMan.GetComponent <MetaDataComponent>(grenade).EntityLifeStage) >= EntityLifeStage.Deleted) { return; } EntitySystem.Get <TriggerSystem>().Trigger(grenade, eventArgs.User); }); } _entMan.DeleteEntity(Owner); });
internal void Update(float frameTime) { if (_meleeWeaponAnimation == null) { return; } _timer += frameTime; var(r, g, b, a) = Vector4.Clamp(_meleeWeaponAnimation.Color + _meleeWeaponAnimation.ColorDelta * _timer, Vector4.Zero, Vector4.One); if (_sprite != null) { _sprite.Color = new Color(r, g, b, a); } var transform = _entMan.GetComponent <TransformComponent>(Owner); switch (_meleeWeaponAnimation.ArcType) { case WeaponArcType.Slash: var angle = Angle.FromDegrees(_meleeWeaponAnimation.Width) / 2; transform.WorldRotation = _baseAngle + Angle.Lerp(-angle, angle, (float)(_timer / _meleeWeaponAnimation.Length.TotalSeconds)); break; case WeaponArcType.Poke: transform.WorldRotation = _baseAngle; if (_sprite != null) { _sprite.Offset -= (0, _meleeWeaponAnimation.Speed *frameTime); } break; } if (_meleeWeaponAnimation.Length.TotalSeconds <= _timer) { _entMan.DeleteEntity(Owner); } }
public override bool Take(IPlayerSession session) { if (Taken) { return(false); } if (string.IsNullOrEmpty(Prototype)) { throw new NullReferenceException("Prototype string cannot be null or empty!"); } var mob = _entMan.SpawnEntity(Prototype, _entMan.GetComponent <TransformComponent>(Owner).Coordinates); if (MakeSentient) { MakeSentientCommand.MakeSentient(mob, _entMan); } mob.EnsureComponent <MindComponent>(); var ghostRoleSystem = EntitySystem.Get <GhostRoleSystem>(); ghostRoleSystem.GhostRoleInternalCreateMindAndTransfer(session, Owner, mob, this); if (++_currentTakeovers < _availableTakeovers) { return(true); } Taken = true; if (_deleteOnSpawn) { _entMan.DeleteEntity(Owner); } return(true); }
private void SubtractContents(FoodRecipePrototype recipe) { var totalReagentsToRemove = new Dictionary <string, FixedPoint2>(recipe.IngredientsReagents); var solutionContainerSystem = EntitySystem.Get <SolutionContainerSystem>(); // this is spaghetti ngl foreach (var item in _storage.ContainedEntities) { if (!_entities.TryGetComponent <SolutionContainerManagerComponent>(item, out var solMan)) { continue; } // go over every solution foreach (var(_, solution) in solMan.Solutions) { foreach (var(reagent, _) in recipe.IngredientsReagents) { // removed everything if (!totalReagentsToRemove.ContainsKey(reagent)) { continue; } if (!solution.ContainsReagent(reagent)) { continue; } var quant = solution.GetReagentQuantity(reagent); if (quant >= totalReagentsToRemove[reagent]) { quant = totalReagentsToRemove[reagent]; totalReagentsToRemove.Remove(reagent); } else { totalReagentsToRemove[reagent] -= quant; } solutionContainerSystem.TryRemoveReagent(item, solution, reagent, quant); } } } foreach (var recipeSolid in recipe.IngredientsSolids) { for (var i = 0; i < recipeSolid.Value; i++) { foreach (var item in _storage.ContainedEntities) { var metaData = _entities.GetComponent <MetaDataComponent>(item); if (metaData.EntityPrototype == null) { continue; } if (metaData.EntityPrototype.ID == recipeSolid.Key) { _storage.Remove(item); _entities.DeleteEntity(item); break; } } } } }
public void PerformAction(EntityUid uid, EntityUid?userUid, IEntityManager entityManager) { entityManager.DeleteEntity(uid); }
//// PUT api/event/5 -- ? //public void Put(int id, [FromBody]string value) //{ //} // DELETE api/event/5 public void Delete(int id) { m_customerManager.DeleteEntity(id); }
// DELETE api/event/5 public void Delete(int id) { m_comapanyManager.DeleteEntity(id); }
async Task <bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { if (!_entMan.TryGetComponent <MindComponent?>(eventArgs.User, out var userMindComponent)) { Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message", ("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-mind-message")))); return(false); } var userMind = userMindComponent.Mind; if (userMind == null) { Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message", ("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-user-mind-message")))); return(false); } if (!_entMan.TryGetComponent <UplinkComponent?>(eventArgs.Using, out var victimUplink)) { Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message", ("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-pda-message")))); return(false); } if (!_entMan.TryGetComponent <TraitorDeathMatchReliableOwnerTagComponent?>(eventArgs.Using, out var victimPDAOwner)) { Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message", ("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-pda-owner-message")))); return(false); } if (victimPDAOwner.UserId == userMind.UserId) { Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message", ("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-pda-different-user-message")))); return(false); } UplinkComponent?userUplink = null; var invSystem = EntitySystem.Get <InventorySystem>(); if (invSystem.TryGetSlotEntity(eventArgs.User, "id", out var pdaUid) && _entMan.TryGetComponent <UplinkComponent>(pdaUid, out var userUplinkComponent)) { userUplink = userUplinkComponent; } if (userUplink == null) { Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message", ("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-no-pda-in-pocket-message")))); return(false); } // We have finally determined both PDA components. FINALLY. var userAccount = userUplink.UplinkAccount; var victimAccount = victimUplink.UplinkAccount; if (userAccount == null) { // This shouldn't even BE POSSIBLE in the actual mode this is meant for. // Advanced Syndicate anti-tampering technology. // Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-tampering-detected")); // if (eventArgs.User.TryGetComponent<DamagableComponent>(out var userDamagable)) // userDamagable.ChangeDamage(DamageType.Shock, 9001, true, null); // ...So apparently, "it probably shouldn't kill people for a mistake". // :( // Give boring error message instead. Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message", ("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-user-no-uplink-account-message")))); return(false); } if (victimAccount == null) { Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-main-message", ("secondMessage", Loc.GetString("traitor-death-match-redemption-component-interact-using-victim-no-uplink-account-message")))); return(false); } // 4 is the per-PDA bonus amount. var accounts = _entMan.EntitySysManager.GetEntitySystem <UplinkAccountsSystem>(); var transferAmount = victimAccount.Balance + 4; accounts.SetBalance(victimAccount, 0); accounts.AddToBalance(userAccount, transferAmount); _entMan.DeleteEntity(victimUplink.Owner); Owner.PopupMessage(eventArgs.User, Loc.GetString("traitor-death-match-redemption-component-interact-using-success-message", ("tcAmount", transferAmount))); return(true); }
//// PUT api/event/5 -- ? //public void Put(int id, [FromBody]string value) //{ //} // DELETE api/event/5 public void Delete(int id) { m_contactManager.DeleteEntity(id); }
/// <summary> /// Gets called by an AreaEffectInceptionComponent. "Clones" Owner into the four directions and copies the /// solution into each of them. /// </summary> public void Spread() { var meta = _entities.GetComponent <MetaDataComponent>(Owner); if (meta.EntityPrototype == null) { Logger.Error("AreaEffectComponent needs its owner to be spawned by a prototype."); return; } var xform = _entities.GetComponent <TransformComponent>(Owner); var solSys = _systems.GetEntitySystem <SolutionContainerSystem>(); if (!_entities.TryGetComponent(xform.GridUid, out IMapGridComponent? gridComp)) { return; } var grid = gridComp.Grid; var origin = grid.TileIndicesFor(xform.Coordinates); DebugTools.Assert(xform.Anchored, "Area effect entity prototypes must be anchored."); void SpreadToDir(Direction dir) { // Currently no support for spreading off or across grids. var index = origin + dir.ToIntVec(); if (!grid.TryGetTileRef(index, out var tile) || tile.Tile.IsEmpty) { return; } foreach (var neighbor in grid.GetAnchoredEntities(index)) { if (_entities.TryGetComponent(neighbor, out SolutionAreaEffectComponent? comp) && comp.Inception == Inception) { return; } // TODO for thindows and the like, need to check the directions that are being blocked. // --> would then also mean you need to check for blockers on the origin tile. if (_entities.TryGetComponent(neighbor, out AirtightComponent? airtight) && airtight.AirBlocked) { return; } } var newEffect = _entities.SpawnEntity( meta.EntityPrototype.ID, grid.GridTileToLocal(index)); if (!_entities.TryGetComponent(newEffect, out SolutionAreaEffectComponent? effectComponent)) { _entities.DeleteEntity(newEffect); return; } if (solSys.TryGetSolution(Owner, SolutionName, out var solution)) { effectComponent.TryAddSolution(solution.Clone()); } effectComponent.Amount = Amount - 1; Inception?.Add(effectComponent); } SpreadToDir(Direction.North); SpreadToDir(Direction.East); SpreadToDir(Direction.South); SpreadToDir(Direction.West); }
//// PUT api/event/5 -- ? //public void Put(int id, [FromBody]string value) //{ //} // DELETE api/event/5 public void Delete(int id) { m_addressManager.DeleteEntity(id); }
public void PerformAction(EntityUid uid, EntityUid?userUid, IEntityManager entityManager) { if (!entityManager.TryGetComponent(uid, out ContainerManagerComponent? containerManager)) { Logger.Warning($"Machine frame entity {uid} did not have a container manager! Aborting build machine action."); return; } if (!entityManager.TryGetComponent(uid, out MachineFrameComponent? machineFrame)) { Logger.Warning($"Machine frame entity {uid} did not have a machine frame component! Aborting build machine action."); return; } if (!EntitySystem.Get <MachineFrameSystem>().IsComplete(machineFrame)) { Logger.Warning($"Machine frame entity {uid} doesn't have all required parts to be built! Aborting build machine action."); return; } if (!containerManager.TryGetContainer(MachineFrameComponent.BoardContainerName, out var entBoardContainer)) { Logger.Warning($"Machine frame entity {uid} did not have the '{MachineFrameComponent.BoardContainerName}' container! Aborting build machine action."); return; } if (!containerManager.TryGetContainer(MachineFrameComponent.PartContainerName, out var entPartContainer)) { Logger.Warning($"Machine frame entity {uid} did not have the '{MachineFrameComponent.PartContainerName}' container! Aborting build machine action."); return; } if (entBoardContainer.ContainedEntities.Count != 1) { Logger.Warning($"Machine frame entity {uid} did not have exactly one item in the '{MachineFrameComponent.BoardContainerName}' container! Aborting build machine action."); } var board = entBoardContainer.ContainedEntities[0]; if (!entityManager.TryGetComponent(board, out MachineBoardComponent? boardComponent)) { Logger.Warning($"Machine frame entity {uid} had an invalid entity in container \"{MachineFrameComponent.BoardContainerName}\"! Aborting build machine action."); return; } entBoardContainer.Remove(board); var transform = entityManager.GetComponent <TransformComponent>(uid); var machine = entityManager.SpawnEntity(boardComponent.Prototype, transform.Coordinates); entityManager.GetComponent <TransformComponent>(machine).LocalRotation = transform.LocalRotation; var boardContainer = machine.EnsureContainer <Container>(MachineFrameComponent.BoardContainerName, out var existed); if (existed) { // Clean that up... boardContainer.CleanContainer(); } var partContainer = machine.EnsureContainer <Container>(MachineFrameComponent.PartContainerName, out existed); if (existed) { // Clean that up, too... partContainer.CleanContainer(); } boardContainer.Insert(board); // Now we insert all parts. foreach (var part in entPartContainer.ContainedEntities.ToArray()) { entPartContainer.ForceRemove(part); partContainer.Insert(part); } var constructionSystem = entityManager.EntitySysManager.GetEntitySystem <ConstructionSystem>(); if (entityManager.TryGetComponent(machine, out ConstructionComponent? construction)) { // We only add these two container. If some construction needs to take other containers into account, fix this. constructionSystem.AddContainer(machine, MachineFrameComponent.BoardContainerName, construction); constructionSystem.AddContainer(machine, MachineFrameComponent.PartContainerName, construction); } if (entityManager.TryGetComponent(machine, out MachineComponent? machineComp)) { constructionSystem.RefreshParts(machineComp); } entityManager.DeleteEntity(uid); }
// DELETE api/Task/{id} public void Delete(int id) { m_taskManager.DeleteEntity(id); }