IEnumerator Respawn(ShipViewComponent shipView, EGID egid) { yield return(_respawnWait); Relocate(shipView, egid); var targetGroup = egid.groupID.SwapTag <AFLOAT>(); if (GroupTagExtensions.Contains <PLAYER_SHIP>(egid.groupID)) { _functions.SwapEntityGroup <PlayerShipDescriptor>(egid, targetGroup); } else { _functions.SwapEntityGroup <AiShipDescriptor>(egid, targetGroup); } shipView.CoinsHud.Visibility = true; var render = false; while (_transitionWait.MoveNext()) { render = !render; shipView.Renderer.Render = render; yield return(_animationWait); } shipView.Renderer.Render = true; shipView.Physics.Enable = true; }
public void MovedTo(ref AiPath aiPath, ExclusiveGroupStruct previousGroup, EGID egid) { if (GroupTagExtensions.Contains <SUNK>(egid.groupID)) { aiPath.Waypoint = (uint)aiPath.Path.Count <uint>(); } }
public void MovedTo(ref ShipViewComponent shipView, ExclusiveGroupStruct previousGroup, EGID egid) { if (GroupTagExtensions.Contains <SUNK>(egid.groupID)) { Respawn(shipView, egid).Run(); } }
public void MovedTo(ref ShipLevelComponent level, ExclusiveGroupStruct previousGroup, EGID egid) { if (GroupTagExtensions.Contains <SUNK>(egid.groupID)) { level.Level = ShipLevel.Normal; level.NextLevel = ShipLevel.Normal; } }
public void MovedTo(ref ShipViewComponent entityComponent, ExclusiveGroupStruct previousGroup, EGID egid) { if (GroupTagExtensions.Contains <SUNK>(egid.groupID)) { entityComponent.Renderer.Render = false; entityComponent.Renderer.Sprite = (int)ShipLevel.Normal; entityComponent.Physics.Enable = false; entityComponent.Explosion.Play = true; entityComponent.Audio.PlayOneShot = ShipAudioType.Sink; entityComponent.CoinsHud.Visibility = false; } else { entityComponent.Explosion.Play = false; } }
public IEnumerator Tick() { while (true) { Process(); yield return(null); } void Process() { var query = entitiesDB.QueryEntities <ShipComponent>(ShipGroups.AliveShipGroups); foreach (var((ships, count), group) in query.groups) { for (var i = 0; i < count; i++) { ref var ship = ref ships[i]; if (!ship.IsSinking) { continue; } ship.IsSinking = false; // note: This semi abstracted engine shouldn't know which descriptor it is changing. var targetGroup = ship.ID.groupID.SwapTag <SUNK>(); if (GroupTagExtensions.Contains <PLAYER_SHIP>(ship.ID.groupID)) { _functions.SwapEntityGroup <PlayerShipDescriptor>(ship.ID, targetGroup); } else { _functions.SwapEntityGroup <AiShipDescriptor>(ship.ID, targetGroup); } } } }
void UpdateTargetPositions() { var(targets, count) = entitiesDB.QueryEntities <AiTarget>(AiGroups.AiShip); var shipViewsQuery = entitiesDB.QueryEntities <ShipViewComponent>(ShipGroups.AliveShipGroups); for (var i = 0; i < count; i++) { ref var target = ref targets[i]; var found = false; if (entitiesDB.FindEGID(target.Locator, out var egid) == false) { continue; } if (GroupTagExtensions.Contains <AFLOAT>(egid.groupID) == false) { continue; } foreach (var((shipViews, shipCount), group) in shipViewsQuery.groups) { for (var j = 0; j < shipCount; j++) { if (shipViews[j].ID == egid) { target.Position = _gridUtils.WorldToCellPosition(shipViews[j].Transform.Position.xy); found = true; break; } } if (found) { break; } } }