/// <summary> /// Checks plant state and updates to correct sprite /// </summary> private void UpdateSprite() { if (plantData == null) { plantSprite.PushClear(); return; } switch (plantCurrentStage) { case PlantSpriteStage.None: plantSprite.PushClear(); break; case PlantSpriteStage.FullyGrown: plantSprite.spriteData = SpriteFunctions.SetupSingleSprite(plantData.FullyGrownSprite); plantSprite.PushTexture(); break; case PlantSpriteStage.Dead: plantSprite.spriteData = SpriteFunctions.SetupSingleSprite(plantData.DeadSprite); plantSprite.PushTexture(); break; case PlantSpriteStage.Growing: if (growingPlantStage >= plantData.GrowthSprites.Count) { Logger.Log($"Plant data does not contain growthsprites for index: {growingPlantStage} in plantData.GrowthSprites. Plant: {plantData.Plantname}"); return; } plantSprite.spriteData = SpriteFunctions.SetupSingleSprite(plantData.GrowthSprites[growingPlantStage]); plantSprite.PushTexture(); break; } }
private void OnContainerExploded() { if (IsConnected) { DisconnectFromConnector(); } if (HasContainerInserted) { EjectInsertedContainer(); } baseSpriteHandler.ChangeSprite(BURST_SPRITE); if (canisterTier > 0) // Tier overlays only for above 0. { int burstTier = canisterTierOverlay.CataloguePage + (canisterTierOverlay.CatalogueCount / 2); canisterTierOverlay.ChangeSprite(burstTier); } pressureIndicatorOverlay.PushClear(); connectorHoseOverlay.PushClear(); tankInsertedOverlay.PushClear(); openValveOverlay.PushClear(); hasBurst = true; }
/// <summary> /// Checks plant state and updates to correct sprite /// </summary> private void UpdateSprite() { if (plantData == null) { plantSprite.PushClear(); return; } switch (plantCurrentStage) { case PlantSpriteStage.None: plantSprite.PushClear(); break; case PlantSpriteStage.FullyGrown: plantSprite.SetSpriteSO(plantData.FullyGrownSpriteSO); break; case PlantSpriteStage.Dead: plantSprite.SetSpriteSO(plantData.DeadSpriteSO); break; case PlantSpriteStage.Growing: if (growingPlantStage >= plantData.GrowthSpritesSOs.Count) { Logger.Log( $"Plant data does not contain growthsprites for index: {growingPlantStage} in plantData.GrowthSprites. Plant: {plantData.PlantName}", Category.Botany); return; } plantSprite.SetSpriteSO(plantData.GrowthSpritesSOs[growingPlantStage]); break; } }
private void SyncStage(PlantSpriteStage newStage) { if (newStage == plantSyncStage) { return; } plantSyncStage = newStage; switch (plantSyncStage) { case PlantSpriteStage.None: plantSprite.PushClear(); break; case PlantSpriteStage.FullyGrown: plantSprite.spriteData = SpriteFunctions.SetupSingleSprite(plantData.FullyGrownSprite); plantSprite.PushTexture(); break; case PlantSpriteStage.Dead: plantSprite.spriteData = SpriteFunctions.SetupSingleSprite(plantData.DeadSprite); plantSprite.PushTexture(); break; case PlantSpriteStage.Growing: plantSprite.spriteData = SpriteFunctions.SetupSingleSprite(plantData.GrowthSprites[growingPlantStage]); plantSprite.PushTexture(); break; } }
public void Start() { waterNotifier.PushClear(); weedNotifier.PushClear(); nutrimentNotifier.PushClear(); harvestNotifier.PushClear(); }
public override void OnSpawnServer(SpawnInfo info) { if (IsOn) { spriteHandlerOverlay.PushTexture(); } else { spriteHandlerOverlay.PushClear(); } base.OnSpawnServer(info); }
public override void OnSpawnServer(SpawnInfo info) { GasIndex = CapableFiltering[initalFilterValue.ToString()]; if (IsOn) { spriteHandlerOverlay.PushTexture(); } else { spriteHandlerOverlay.PushClear(); } base.OnSpawnServer(info); }
public override void Start() { pipeData.PipeAction = new MonoActions(); base.Start(); if (IsOn) { spriteHandlerOverlay.PushTexture(); } else { spriteHandlerOverlay.PushClear(); } }
public override void Start() { GasIndex = CapableFiltering[initalFilterValue.ToString()]; pipeData.PipeAction = new MonoActions(); base.Start(); if (IsOn) { spriteHandlerOverlay.PushTexture(); } else { spriteHandlerOverlay.PushClear(); } }
/// <summary> /// Shows high weeds sprite on tray if flag is set and tray is not a soil pile /// </summary> /// <param name="oldNotifier"></param> /// <param name="newNotifier"></param> private void UpdateWeedsFlag(bool oldNotifier, bool newNotifier) { if (isSoilPile) { return; } showWeedsFlag = newNotifier; if (showWeedsFlag) { weedNotifier.PushTexture(); } else { weedNotifier.PushClear(); } }
public void Pool() { IconBackground.ChangeSpriteVariant(0, false); IconFront.ChangeSpriteVariant(0, false); IconBackground.SetSpriteSO(DefaultIconBackground, Network: false); IconFront.PushClear(false); this.gameObject.SetActive(false); }
public void Pool() { IconBackground.ChangeSpriteVariant(0); IconFront.ChangeSpriteVariant(0); IconBackground.SetInfo(DefaultIconBackground.Data); IconFront.PushClear(); this.gameObject.SetActive(false); }
private void SyncStage(PlantSpriteStage newStage) { if (newStage == plantSyncStage) { return; } plantSyncStage = newStage; if (plantData == null) { //FIXME: BOD PLZ FIX BOTANY PLANT DATA IS NULL! return; } switch (plantSyncStage) { case PlantSpriteStage.None: plantSprite.PushClear(); break; case PlantSpriteStage.FullyGrown: plantSprite.spriteData = SpriteFunctions.SetupSingleSprite(plantData.FullyGrownSprite); plantSprite.PushTexture(); break; case PlantSpriteStage.Dead: plantSprite.spriteData = SpriteFunctions.SetupSingleSprite(plantData.DeadSprite); plantSprite.PushTexture(); break; case PlantSpriteStage.Growing: if (growingPlantStage >= plantData.GrowthSprites.Count) { Logger.Log($"Plant data does not contain growthsprites for index: {growingPlantStage} in plantData.GrowthSprites. Plant: {plantData.Plantname}"); return; } plantSprite.spriteData = SpriteFunctions.SetupSingleSprite(plantData.GrowthSprites[growingPlantStage]); plantSprite.PushTexture(); break; } //Force a refresh on nearby clients if (isServer) { SendUpdateToNearbyPlayers(); } }
private void SyncWeed(bool newNotifier) { if (isSoilPile || newNotifier == syncWeedNotifier) { return; } syncWeedNotifier = newNotifier; if (syncWeedNotifier) { weedNotifier.PushTexture(); } else { weedNotifier.PushClear(); } }
void UpdateSpriteBinState() { if (MachineUnattached) { baseSpriteHandler.ChangeSprite(1); overlaysSpriteHandler.PushClear(); return; } switch (binState) { case BinState.Disconnected: rechargeSFX.Stop(); baseSpriteHandler.ChangeSprite(0); overlaysSpriteHandler.PushClear(); break; case BinState.Off: rechargeSFX.Stop(); baseSpriteHandler.ChangeSprite(0); overlaysSpriteHandler.PushClear(); break; case BinState.Ready: rechargeSFX.Stop(); baseSpriteHandler.ChangeSprite(0); overlaysSpriteHandler.ChangeSprite(1); break; case BinState.Flushing: rechargeSFX.Stop(); baseSpriteHandler.ChangeSprite(2); overlaysSpriteHandler.PushClear(); break; case BinState.Recharging: rechargeSFX.Play(); baseSpriteHandler.ChangeSprite(0); overlaysSpriteHandler.ChangeSprite(0); break; } BinStateUpdated?.Invoke(); }
private void UpdateMe() { currentTime += Time.deltaTime; if (currentTime >= lifeTime) { currentTime = 0; spriteHandler.PushClear(false); Despawn.ClientSingle(gameObject); } }
private void SetEnergySprite() { if (energy <= 0) { topSpriteHandler.PushClear(); return; } if (energy <= maxEnergy / 3) { powerSpriteHandler.ChangeSprite(0); } else if (energy <= maxEnergy / 1.5) { powerSpriteHandler.ChangeSprite(1); } else { powerSpriteHandler.ChangeSprite(2); } }
private void UpdateSpriteBinState() { if (MachineUnattached) { baseSpriteHandler.ChangeSprite((int)BinSprite.Sideways); overlaysSpriteHandler.PushClear(); return; } switch (binState) { case BinState.Disconnected: baseSpriteHandler.ChangeSprite((int)BinSprite.Upright); overlaysSpriteHandler.PushClear(); break; case BinState.Off: baseSpriteHandler.ChangeSprite((int)BinSprite.Upright); overlaysSpriteHandler.PushClear(); break; case BinState.Ready: baseSpriteHandler.ChangeSprite((int)BinSprite.Upright); overlaysSpriteHandler.ChangeSprite((int)BinOverlaySprite.Ready); break; case BinState.Flushing: baseSpriteHandler.ChangeSprite((int)BinSprite.Flushing); overlaysSpriteHandler.PushClear(); break; case BinState.Recharging: baseSpriteHandler.ChangeSprite((int)BinSprite.Upright); overlaysSpriteHandler.ChangeSprite((int)BinOverlaySprite.Charging); break; } BinStateUpdated?.Invoke(); }
private IEnumerator RunLandingSequence() { GameObject targetReticule = landingSpriteHandler.gameObject; GameObject dropPod = baseSpriteHandler.gameObject; // Initialise target reticule for animating. targetReticule.LeanAlpha(0.25f, 0); targetReticule.transform.localScale = Vector3.one * 1.5f; // Initialise drop pod sprite to the start of falling animation. baseSpriteHandler.ChangeSprite((int)BaseSprite.Falling, false); dropPod.transform.localScale = Vector3.zero; Vector3 localPos = dropPod.transform.localPosition; localPos.y = DROP_HEIGHT; dropPod.transform.localPosition = localPos; registerObject.Passable = true; // ClosetControl initialises, redisplaying the door, so wait a frame... yield return(WaitFor.EndOfFrame); doorSpriteHandler.PushClear(false); // Begin the drop animation. dropPod.LeanScale(Vector3.one, TRAVEL_TIME); dropPod.LeanMoveLocalY(0, TRAVEL_TIME); // Animate the target reticule. targetReticule.LeanScale(Vector3Int.one, TRAVEL_TIME / 2); targetReticule.LeanRotateZ(-270, TRAVEL_TIME); targetReticule.LeanAlpha(0.75f, TRAVEL_TIME / 2); yield return(WaitFor.Seconds(TRAVEL_TIME)); // Swap to stationary drop pod. if (IsServer) { closetControl.ServerToggleLocked(false); } baseSpriteHandler.ChangeSprite((int)BaseSprite.Stationary, false); doorSpriteHandler.PushTexture(false); landingSpriteHandler.PushClear(false); registerObject.Passable = false; // Create a small explosion to apply damage to objects underneath. var matrixInfo = MatrixManager.AtPoint(WorldPosition, IsServer); Explosion.StartExplosion(registerObject.LocalPosition, EXPLOSION_STRENGTH, matrixInfo.Matrix); isLanding = false; }
private void SyncWeed(bool newNotifier) { if (isSoilPile || newNotifier == syncWeedNotifier) { return; } syncWeedNotifier = newNotifier; if (syncWeedNotifier) { weedNotifier.PushTexture(); } else { weedNotifier.PushClear(); } //Force a refresh on nearby clients if (isServer) { SendUpdateToNearbyPlayers(); } }
public void TogglePower(bool newIsOn) { if (newIsOn) { isOn = true; } else { isOn = false; RemoveAllShields(); topSpriteHandler.PushClear(); powerSpriteHandler.PushClear(); healthSpriteHandler.PushClear(); energy = 0; } }
/// <summary> /// Shows harvest ready sprite on tray if flag is set and tray is not a soil pile /// </summary> /// <param name="oldNotifier"></param> /// <param name="newNotifier"></param> private void UpdateHarvestFlag(bool oldNotifier, bool newNotifier) { if (isSoilPile) { return; } showHarvestFlag = newNotifier; if (showHarvestFlag) { harvestNotifier.PushTexture(); } else { harvestNotifier.PushClear(); } }
/// <summary> /// Shows low nutriment sprite on tray if flag is set and tray is not a soil pile /// </summary> /// <param name="oldNotifier"></param> /// <param name="newNotifier"></param> private void UpdateNutrimentFlag(bool oldNotifier, bool newNotifier) { if (isSoilPile) { return; } showNutrimenetFlag = newNotifier; if (showNutrimenetFlag) { nutrimentNotifier.PushTexture(); } else { nutrimentNotifier.PushClear(); } }
private void SyncNutriment(bool newNotifier) { if (isSoilPile || newNotifier == syncNutrimentNotifier) { return; } syncNutrimentNotifier = newNotifier; if (syncNutrimentNotifier) { nutrimentNotifier.PushTexture(); } else { nutrimentNotifier.PushClear(); } }
/// <summary> /// Shows low water sprite on tray if flag is set and tray is not a soil pile /// </summary> /// <param name="oldNotifier"></param> /// <param name="newNotifier"></param> private void UpdateWaterFlag(bool oldNotifier, bool newNotifier) { if (isSoilPile) { return; } if (oldNotifier != newNotifier) { showWaterFlag = newNotifier; if (showWaterFlag) { waterNotifier.PushTexture(); } else { waterNotifier.PushClear(); } } }
private IEnumerator RunLandingSequence() { GameObject targetReticule = landingSpriteHandler.gameObject; GameObject dropPod = baseSpriteHandler.gameObject; // Initialise drop pod sprite to the start of falling animation. baseSpriteHandler.ChangeSprite((int)BaseSprite.Falling, false); registerObject.SetPassable(false, true); // ClosetControl initialises, redisplaying the door, so wait a frame... yield return(WaitFor.EndOfFrame); doorSpriteHandler.PushClear(false); // Animate the drop-pod falling. dropPod.LeanScale(Vector3.one, TRAVEL_TIME).setFrom(Vector3.zero).setEaseInQuad(); dropPod.LeanMoveLocalY(0, TRAVEL_TIME).setFrom(DROP_HEIGHT).setEaseInQuad(); // Animate the target reticule. targetReticule.LeanScale(Vector3.one, TRAVEL_TIME / 2f).setFrom(new Vector3(1.5f, 1.5f, 1)).setEaseOutQuad(); targetReticule.LeanRotateZ(-270, TRAVEL_TIME); targetReticule.LeanAlpha(0.75f, TRAVEL_TIME / 2f).setFrom(0.25f).setEaseOutQuad(); yield return(WaitFor.Seconds(TRAVEL_TIME)); // Swap to stationary drop pod. baseSpriteHandler.ChangeSprite((int)BaseSprite.Stationary, false); doorSpriteHandler.PushTexture(false); landingSpriteHandler.PushClear(false); registerObject.SetPassable(false, false); // Create a small explosion to apply damage to objects underneath. var matrixInfo = MatrixManager.AtPoint(WorldPosition, IsServer); Explosion.StartExplosion(registerObject.WorldPositionServer, EXPLOSION_STRENGTH); isLanding = false; }
public void RefreshSprites() { HashSet <IntrinsicElectronicData> connections = new HashSet <IntrinsicElectronicData>(); ElectricityFunctions.SwitchCaseConnections( Wire.transform.localPosition, Wire.Matrix, connectionTypes, Connection.MachineConnect, Wire.InData, connections); HashSet <OrientationEnum> activeDirections = new HashSet <OrientationEnum>(); foreach (IntrinsicElectronicData connection in connections) { Vector3 vector = (connection.Present.transform.localPosition - Wire.transform.localPosition).CutToInt(); activeDirections.Add(Orientation.From(vector).AsEnum()); } foreach (var kvp in spriteHandlers) { SpriteHandler spriteHandler = kvp.Value; if (activeDirections.Contains(kvp.Key)) { if (spriteHandler.CurrentSpriteIndex == -1) { spriteHandler.ChangeSprite(0); } else { spriteHandler.PushTexture(); } } else { spriteHandler.PushClear(); } } }
private void ServerToggleOutputModeOff() { outputEnabledIndicator.PushClear(); electricalNodeControl.TurnOffSupply(); outputEnabled = false; }
void UpdateMe() { if (PlayerManager.LocalPlayer == null) { return; } if (PlayerManager.LocalPlayerScript.IsGhost) { if (humanUI) { DisableAll(); } return; } if (!PlayerManager.LocalPlayerScript.IsGhost && !humanUI) { EnableAlwaysVisible(); } float temperature = PlayerManager.LocalPlayerScript.playerHealth.RespiratorySystem.Temperature; float pressure = PlayerManager.LocalPlayerScript.playerHealth.RespiratorySystem.Pressure; if (temperature < 110) { SetSpecificVisibility(true, coldAlert); } else { SetSpecificVisibility(false, coldAlert); } if (temperature > 510) { SetSpecificVisibility(true, heatAlert); } else { SetSpecificVisibility(false, heatAlert); } if (temperature > 260 && temperature < 360) { SetSpecificVisibility(false, temperatureAlert.gameObject); } else { SetSpecificVisibility(true, temperatureAlert.gameObject); temperatureAlert.SetTemperatureSprite(temperature); } if (pressure > 50 && pressure < 325) { SetSpecificVisibility(false, pressureAlert.gameObject); } else { SetSpecificVisibility(true, pressureAlert.gameObject); pressureAlert.SetPressureSprite(pressure); } SetSpecificVisibility(PlayerManager.LocalPlayerScript.playerHealth.RespiratorySystem.IsSuffocating, oxygenAlert); SetSpecificVisibility(false, toxinAlert); switch (PlayerManager.LocalPlayerScript.playerHealth.HealthStateController.HungerState) { case HungerState.Full: hungerAlert.gameObject.SetActive(true); hungerAlert.ChangeSprite(0); break; case HungerState.Normal: hungerAlert.gameObject.SetActive(false); hungerAlert.PushClear(); break; case HungerState.Hungry: hungerAlert.gameObject.SetActive(true); hungerAlert.ChangeSprite(1); break; case HungerState.Malnourished: hungerAlert.gameObject.SetActive(true); hungerAlert.ChangeSprite(1); break; case HungerState.Starving: hungerAlert.gameObject.SetActive(true); hungerAlert.ChangeSprite(2); break; default: hungerAlert.gameObject.SetActive(false); hungerAlert.PushClear(); break; } switch (PlayerManager.LocalPlayerScript.playerHealth.HealthStateController.BleedingState) { case BleedingState.None: bleedingAlert.gameObject.SetActive(false); bleedingAlert.PushClear(); break; case BleedingState.VeryLow: bleedingAlert.gameObject.SetActive(true); bleedingAlert.ChangeSprite(0); break; case BleedingState.Low: bleedingAlert.gameObject.SetActive(true); bleedingAlert.ChangeSprite(1); break; case BleedingState.Medium: bleedingAlert.gameObject.SetActive(true); bleedingAlert.ChangeSprite(2); break; case BleedingState.High: bleedingAlert.gameObject.SetActive(true); bleedingAlert.ChangeSprite(3); break; case BleedingState.UhOh: bleedingAlert.gameObject.SetActive(true); bleedingAlert.ChangeSprite(4); break; default: bleedingAlert.gameObject.SetActive(false); bleedingAlert.PushClear(); break; } // if (!PlayerManager.Equipment.HasInternalsEquipped() && oxygenButton.IsInteractable()) // { // EventManager.Broadcast(EVENT.DisableInternals); // oxygenButton.interactable = false; // } }
public static SpriteUpdateMessage.NetMessage Deserialize(this NetworkReader reader) { var message = new SpriteUpdateMessage.NetMessage(); SpriteUpdateMessage.SpriteUpdateEntry UnprocessedData = null; while (true) { UnprocessedData = null; bool ProcessSection = true; uint NetID = reader.ReadUInt32(); if (NetID == 0) { break; } if (NetworkIdentity.spawned.ContainsKey(NetID) == false || NetworkIdentity.spawned[NetID] == null) { ProcessSection = false; } string Name = reader.ReadString(); if (ProcessSection == false || NetworkIdentity.spawned.ContainsKey(NetID) == false || SpriteHandlerManager.PresentSprites.ContainsKey(NetworkIdentity.spawned[NetID]) == false || SpriteHandlerManager.PresentSprites[NetworkIdentity.spawned[NetID]].ContainsKey(Name) == false) { ProcessSection = false; } if (ProcessSection == false) { UnprocessedData = new SpriteUpdateMessage.SpriteUpdateEntry(); UnprocessedData.name = Name; UnprocessedData.id = NetID; } SpriteHandler SP = null; if (ProcessSection) { SP = SpriteHandlerManager.PresentSprites[NetworkIdentity.spawned[NetID]][Name]; } while (true) { byte Operation = reader.ReadByte(); if (Operation == 255) { if (ProcessSection == false) { SpriteUpdateMessage.UnprocessedData.Add(UnprocessedData); } break; } if (Operation == 1) { int SpriteID = reader.ReadInt32(); if (ProcessSection) { SP.SetSpriteSO(SpriteCatalogue.Instance.Catalogue[SpriteID], Network: false); } else { UnprocessedData.call.Add(SpriteUpdateMessage.SpriteOperation.PresentSpriteSet); UnprocessedData.arg.Add(SpriteID); } } if (Operation == 2) { int Variant = reader.ReadInt32(); if (ProcessSection) { SP.ChangeSpriteVariant(Variant, NetWork: false); } else { UnprocessedData.call.Add(SpriteUpdateMessage.SpriteOperation.VariantIndex); UnprocessedData.arg.Add(Variant); } } if (Operation == 3) { int Sprite = reader.ReadInt32(); if (ProcessSection) { SP.ChangeSprite(Sprite, false); } else { UnprocessedData.call.Add(SpriteUpdateMessage.SpriteOperation.CataloguePage); UnprocessedData.arg.Add(Sprite); } } if (Operation == 4) { int SpriteAnimate = reader.ReadInt32(); if (ProcessSection) { SP.AnimateOnce(SpriteAnimate, false); } else { UnprocessedData.call.Add(SpriteUpdateMessage.SpriteOperation.AnimateOnce); UnprocessedData.arg.Add(SpriteAnimate); } } if (Operation == 5) { if (ProcessSection) { SP.PushTexture(false); } else { UnprocessedData.call.Add(SpriteUpdateMessage.SpriteOperation.PushTexture); } } if (Operation == 6) { if (ProcessSection) { SP.Empty(false); } else { UnprocessedData.call.Add(SpriteUpdateMessage.SpriteOperation.Empty); } } if (Operation == 7) { if (ProcessSection) { SP.PushClear(false); } else { UnprocessedData.call.Add(SpriteUpdateMessage.SpriteOperation.PushClear); } } if (Operation == 8) { if (ProcessSection) { SP.ClearPallet(false); } else { UnprocessedData.call.Add(SpriteUpdateMessage.SpriteOperation.ClearPallet); } } if (Operation == 9) { Color TheColour = reader.ReadColor(); if (ProcessSection) { SP.SetColor(TheColour, false); } else { UnprocessedData.call.Add(SpriteUpdateMessage.SpriteOperation.SetColour); UnprocessedData.arg.Add(Convert.ToChar(Mathf.RoundToInt(TheColour.r * 255))); UnprocessedData.arg.Add(Convert.ToChar(Mathf.RoundToInt(TheColour.g * 255))); UnprocessedData.arg.Add(Convert.ToChar(Mathf.RoundToInt(TheColour.b * 255))); UnprocessedData.arg.Add(Convert.ToChar(Mathf.RoundToInt(TheColour.a * 255))); } } if (Operation == 10) { int paletteCount = reader.ReadByte(); List <Color> Colours = new List <Color>(); for (int i = 0; i < paletteCount; i++) { Colours.Add(reader.ReadColor()); } if (ProcessSection) { SP.SetPaletteOfCurrentSprite(Colours, false); } else { UnprocessedData.call.Add(SpriteUpdateMessage.SpriteOperation.Pallet); UnprocessedData.arg.Add(Convert.ToChar(paletteCount)); foreach (var color in Colours) { UnprocessedData.arg.Add(Convert.ToChar(Mathf.RoundToInt(color.r * 255))); UnprocessedData.arg.Add(Convert.ToChar(Mathf.RoundToInt(color.g * 255))); UnprocessedData.arg.Add(Convert.ToChar(Mathf.RoundToInt(color.b * 255))); UnprocessedData.arg.Add(Convert.ToChar(Mathf.RoundToInt(color.a * 255))); } } } } } return(message); }