private void ChangeDirection() { int count = (int)CurrentDirection + 1; if (count > 11) { count = 0; } CurrentDirection = (ConveyorDirection)count; spriteHandler.ChangeSpriteVariant(count); }
public void RotateTile(float degrees) { if (!selectedTiles[0].GetComponent <ConveyorSelector>().canRotate) { return; } selectedTiles[0].transform.Rotate(0, 0, degrees); /* * if(degrees > 0) * { * Microsoft.VisualStudio.Utilities.RotateRight(manager.selectedTiles[0].GetComponent<ConveyorDirection>().shifter, 1); * } * else * { * Microsoft.VisualStudio.Utilities.RotateLeft(manager.selectedTiles[0].GetComponent<ConveyorDirection>().shifter, 1); * } */ ConveyorDirection shorten = selectedTiles[0].GetComponent <ConveyorDirection>(); MultiExitTiles multiExitTiles = selectedTiles[0].GetComponent <MultiExitTiles>(); if (degrees > 0) { uint right = RotateRight((byte)shorten.direction, 1); shorten.direction = (ConveyorDirection.Direction)right; if (multiExitTiles != null) { bool isOdd = (multiExitTiles.outputDirections & ConveyorDirection.Direction.Left) != 0; byte temp = RotateRight((byte)multiExitTiles.outputDirections, 1, false); if (isOdd) { temp += 8; } multiExitTiles.outputDirections = (ConveyorDirection.Direction)temp; } } else { uint left = RotateLeft((byte)shorten.direction, 1); shorten.direction = (ConveyorDirection.Direction)left; if (multiExitTiles != null) { byte temp = RotateLeft((byte)multiExitTiles.outputDirections, 1, false); temp %= 15; multiExitTiles.outputDirections = (ConveyorDirection.Direction)temp; } } }
private void OnStart() { registerTile = GetComponent <RegisterTile>(); CurrentDirection = MappedDirection; SyncInverted = Inverted; if (isServer) { UpdateDirection(CurrentDirection); } spriteHandler.ChangeSprite((int)CurrentStatus); spriteHandler.ChangeSpriteVariant((int)CurrentDirection); }
public void SetBeltFromBuildMenu(ConveyorDirection direction) { CurrentDirection = direction; //Discover any neighbours: for (int i = 0; i < searchDirs.Length; i++) { var conveyorBelt = registerTile.Matrix.GetFirst <ConveyorBelt>(registerTile.LocalPosition + searchDirs[i].To3Int(), true); if (conveyorBelt != null) { if (conveyorBelt.AssignedSwitch != null) { conveyorBelt.AssignedSwitch.AddConveyorBelt(new List <ConveyorBelt> { this }); conveyorBelt.SetState(conveyorBelt.CurrentStatus); break; } } } }
public void ServerPerformInteraction(HandApply interaction) { if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Wrench)) { //deconsruct ToolUtils.ServerUseToolWithActionMessages(interaction, 2f, "You start deconstructing the conveyor belt...", $"{interaction.Performer.ExpensiveName()} starts deconstructing the conveyor belt...", "You deconstruct the conveyor belt.", $"{interaction.Performer.ExpensiveName()} deconstructs the conveyor belt.", () => { Spawn.ServerPrefab(CommonPrefabs.Instance.Metal, SpawnDestination.At(gameObject), 5); Despawn.ServerSingle(gameObject); }); } else if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Screwdriver)) //change direction { int count = (int)CurrentDirection + 1; if (count > 11) { count = 0; } ToolUtils.ServerUseToolWithActionMessages(interaction, 1f, "You start redirecting the conveyor belt...", $"{interaction.Performer.ExpensiveName()} starts redirecting the conveyor belt...", "You redirect the conveyor belt.", $"{interaction.Performer.ExpensiveName()} redirects the conveyor belt.", () => { CurrentDirection = (ConveyorDirection)count; spriteHandler.ChangeSpriteVariant(count); }); } }
public void SyncDirection(ConveyorDirection oldValue, ConveyorDirection newValue) { CurrentDirection = newValue; GetPositionOffset(); RefreshSprites(); }
void Start() { select = gameObject.GetComponent <ConveyorDirection>();//cache the ConveyorDirection }
public void UpdateDirection(ConveyorDirection newValue) { CurrentDirection = newValue; }
public void SyncDirection(ConveyorDirection oldValue, ConveyorDirection newValue) { CurrentDirection = newValue; }