/// <summary> /// Ejects contents when they come from the same direction the entry is facing. /// </summary> public override Direction NextDirection(DisposalHolderComponent holder) { if (holder.PreviousDirectionFrom != Direction.Invalid) { return(Direction.Invalid); } return(ConnectableDirections()[0]); }
public bool TryInsert(DisposalHolderComponent holder) { if (!Contents.Insert(holder.Owner)) { return(false); } holder.EnterTube(this); return(true); }
public override Direction NextDirection(DisposalHolderComponent holder) { var directions = ConnectableDirections(); var previousDF = holder.PreviousDirectionFrom; if (previousDF == Direction.Invalid) { return(directions[0]); } return(previousDF == directions[0] ? directions[1] : directions[0]); }
/// <summary> /// Ejects contents when they come from the same direction the entry is facing. /// </summary> public override Direction NextDirection(DisposalHolderComponent holder) { if (holder.PreviousTube != null && DirectionTo(holder.PreviousTube) == ConnectableDirections()[0]) { var invalidDirections = new[] { ConnectableDirections()[0], Direction.Invalid }; var directions = Enum.GetValues(typeof(Direction)) .Cast <Direction>().Except(invalidDirections).ToList(); return(_random.Pick(directions)); } return(ConnectableDirections()[0]); }
private void UpdateComp(DisposalHolderComponent holder, float frameTime) { while (frameTime > 0) { var time = frameTime; if (time > holder.TimeLeft) { time = holder.TimeLeft; } holder.TimeLeft -= time; frameTime -= time; var currentTube = holder.CurrentTube; if (currentTube == null || currentTube.Deleted) { ExitDisposals((holder).Owner); break; } if (holder.TimeLeft > 0) { var progress = 1 - holder.TimeLeft / holder.StartingTime; var origin = EntityManager.GetComponent <TransformComponent>(currentTube.Owner).Coordinates; var destination = holder.CurrentDirection.ToVec(); var newPosition = destination * progress; EntityManager.GetComponent <TransformComponent>(holder.Owner).Coordinates = origin.Offset(newPosition); continue; } // Past this point, we are performing inter-tube transfer! // Remove current tube content currentTube.Contents.ForceRemove(holder.Owner); // Find next tube var nextTube = _disposalTubeSystem.NextTubeFor(currentTube.Owner, holder.CurrentDirection); if (nextTube == null || nextTube.Deleted) { ExitDisposals((holder).Owner); break; } // Perform remainder of entry process if (!EnterTube((holder).Owner, nextTube.Owner, holder, null, nextTube, null)) { break; } } }
public override Direction NextDirection(DisposalHolderComponent holder) { var directions = ConnectableDirections(); var previousTube = holder.PreviousTube; if (previousTube == null) { return(directions[0]); } var previousDirection = DirectionTo(previousTube); return(previousDirection == directions[0] ? directions[1] : directions[0]); }
public override Direction NextDirection(DisposalHolderComponent holder) { var directions = ConnectableDirections(); var previousTube = holder.PreviousTube; var forward = directions[0]; if (previousTube == null) { return(forward); } var backward = directions[1]; return(DirectionTo(previousTube) == forward ? backward : forward); }
public override Direction NextDirection(DisposalHolderComponent holder) { var directions = ConnectableDirections(); var previousDF = holder.PreviousDirectionFrom; var forward = directions[0]; if (previousDF == Direction.Invalid) { return(forward); } var backward = directions[1]; return(previousDF == forward ? backward : forward); }
public override Direction NextDirection(DisposalHolderComponent holder) { holder.Tags.Add(_tag); return(base.NextDirection(holder)); }
public abstract Direction NextDirection(DisposalHolderComponent holder);