/// <summary> /// Sets up the sprite for a specific body part /// </summary> private void SetupBodySprite(SpriteDataSO variantBodypart, string bodypartKey, Color?color = null) { if (variantBodypart != null && variantBodypart.Variance.Count > 0) { SetupSprite(variantBodypart, bodypartKey, color); } }
/// <summary> /// Mutates the plant instance this is run against /// </summary> /// <param name="plantData"></param> public void MutateTo(PlantData plantData) { if (plantData.plantEvolveStats == null) { return; } PlantName = plantData.PlantName; ProduceObject = plantData.ProduceObject; GrowthSpritesSOs = plantData.GrowthSpritesSOs; FullyGrownSpriteSO = plantData.FullyGrownSpriteSO; DeadSpriteSO = plantData.DeadSpriteSO; MutatesInToGameObject = plantData.MutatesInToGameObject; var evolveStats = plantData.plantEvolveStats; WeedResistance = AddToStat(WeedResistance, evolveStats.WeedResistanceChange); WeedGrowthRate = AddToStat(WeedGrowthRate, evolveStats.WeedGrowthRateChange); GrowthSpeed = AddToStat(GrowthSpeed, evolveStats.GrowthSpeedChange); Potency = AddToStat(Potency, evolveStats.PotencyChange); Endurance = AddToStat(Endurance, evolveStats.EnduranceChange); Yield = AddToStat(Yield, evolveStats.YieldChange); Lifespan = AddToStat(Lifespan, evolveStats.LifespanChange); PlantTrays = (evolveStats.PlantTrays.Union(PlantTrays)).ToList(); CombineReagentProduction(evolveStats.ReagentProduction); }
public void SetSpriteSO(SpriteDataSO NewspriteDataSO, Color?color = null, int NewvariantIndex = -1, bool Network = true) { if (NewspriteDataSO != PresentSpriteSet) { isPaletteSet = false; PresentSpriteSet = NewspriteDataSO; // TODO: Network, change to network catalogue message // See https://github.com/unitystation/unitystation/pull/5675#pullrequestreview-540239428 cataloguePage = SubCatalogue.FindIndex(SO => SO == NewspriteDataSO); PushTexture(Network); if (Network) { NetUpdate(NewspriteDataSO); } OnSpriteDataSOChanged?.Invoke(NewspriteDataSO); } if (color != null) { SetColor(color.GetValueOrDefault(Color.white), Network); } if (NewvariantIndex > -1) { ChangeSpriteVariant(NewvariantIndex, Network); } }
/// <summary> /// Mutates the plant instance this is run against /// </summary> /// <param name="_PlantData.plantEvolveStats"></param> public void MutateTo(PlantData _PlantData) { if (_PlantData.plantEvolveStats == null) { return; } Plantname = _PlantData.Plantname; Description = _PlantData.Description; Name = _PlantData.Name; ProduceObject = _PlantData.ProduceObject; GrowthSpritesSOs = _PlantData.GrowthSpritesSOs; FullyGrownSpriteSO = _PlantData.FullyGrownSpriteSO; DeadSpriteSO = _PlantData.DeadSpriteSO; MutatesInToGameObject = _PlantData.MutatesInToGameObject; WeedResistance = WeedResistance + _PlantData.plantEvolveStats.WeedResistanceChange; WeedGrowthRate = WeedGrowthRate + _PlantData.plantEvolveStats.WeedGrowthRateChange; GrowthSpeed = GrowthSpeed + _PlantData.plantEvolveStats.GrowthSpeedChange; Potency = Mathf.Clamp(Potency + _PlantData.plantEvolveStats.PotencyChange, 0, MAX_POTENCY); Endurance = Endurance + _PlantData.plantEvolveStats.EnduranceChange; Yield = Yield + _PlantData.plantEvolveStats.YieldChange; Lifespan = Lifespan + _PlantData.plantEvolveStats.LifespanChange; PlantTrays = (_PlantData.plantEvolveStats.PlantTrays.Union(PlantTrays)).ToList(); CombineReagentProduction(_PlantData.plantEvolveStats.ReagentProduction); }
/// <summary> /// Sets up the sprite for a specific customisation /// </summary> private void SetupCustomisationSprite(CustomisationType customisationType, string customisationKey, string customisationName, Color?color = null) { if (customisationName != "None") { SpriteDataSO spriteDataSO = PlayerCustomisationDataSOs.Instance.Get(customisationType, ThisCharacter.Gender, customisationName).SpriteEquipped; SetupSprite(spriteDataSO, customisationKey, color); } }
public DatabaseEntry(string _guid, GameObject _gameObject, SpriteHandler _spriteHandler, SpriteDataSO _spriteDataSO, Texture2D _generatedTexture2D) { guid = _guid; gameObject = _gameObject; spriteHandler = _spriteHandler; spriteDataSO = _spriteDataSO; generatedTexture2D = _generatedTexture2D; }
public DatabaseEntry(SpriteDataSO _spriteDataSO, Texture2D _generatedTexture2D, SpriteDataSO.Frame _PresentFrame) { spriteDataSO = _spriteDataSO; Textdict = new Dictionary <SpriteDataSO.Frame, Texture2D> { [_PresentFrame] = _generatedTexture2D }; TimeSet = DateTime.Now; PresentFrame = _PresentFrame; }
public void AddToCatalogue(SpriteDataSO spriteDataSO) { for (int i = 0; i < Catalogue.Count; i++) { if (Catalogue[i] == null) { Catalogue[i] = spriteDataSO; return; } } Catalogue.Add(spriteDataSO); }
/// <summary> /// Sets the sprite of the action button. /// </summary> public static void SetSpriteSO(IActionGUI iActionGUI, SpriteDataSO sprite, bool networked = true) { if (Instance.DicIActionGUI.ContainsKey(iActionGUI)) { var _UIAction = Instance.DicIActionGUI[iActionGUI]; _UIAction.IconFront.SetSpriteSO(sprite, Network: networked); } else { Logger.Log("iActionGUI Not present", Category.UI); } }
public void AddToCatalogue(SpriteDataSO spriteDataSO) { // for (int i = 0; i < Catalogue.Count; i++) // { // if (Catalogue[i] == null) // { // Catalogue[i] = spriteDataSO; // return; // } // } Catalogue.Add(spriteDataSO); }
public static SpriteDataSO FilloutData(TextAsset EquippedData, Sprite[] Sprites, SpriteDataSO SpriteData) { SpriteJson spriteJson = null; if (EquippedData != null) { spriteJson = JsonConvert.DeserializeObject <SpriteJson>(EquippedData.text); } else { if (Sprites.Length > 1) { Logger.LogError("OH NO json File wasn't found for " + Sprites[0].name, Category.Editor); } SpriteData.Variance.Add(new SpriteDataSO.Variant()); SpriteData.Variance[0].Frames.Add(new SpriteDataSO.Frame()); SpriteData.Variance[0].Frames[0].sprite = Sprites[0]; return(SpriteData); } int variance = 0; int frame = 0; for (int J = 0; J < spriteJson.Number_Of_Variants; J++) { SpriteData.Variance.Add(new SpriteDataSO.Variant()); } foreach (var SP in Sprites) { var info = new SpriteDataSO.Frame(); info.sprite = SP; if (spriteJson.Delays.Count > 0) { info.secondDelay = spriteJson.Delays[variance][frame]; } SpriteData.Variance[variance].Frames.Add(info); if (variance >= (spriteJson.Number_Of_Variants - 1)) { variance = 0; frame++; } else { variance++; } } return(SpriteData); }
/// <summary> /// Sets the sprite of the action button. /// </summary> public static void SetSpriteSO(IActionGUI iActionGUI, SpriteDataSO sprite, bool networked = true, List <Color> palette = null) { Debug.Assert(!(sprite.IsPalette && palette == null), "Paletted sprites should never be set without a palette"); if (Instance.DicIActionGUI.ContainsKey(iActionGUI)) { var _UIAction = Instance.DicIActionGUI[iActionGUI]; _UIAction.IconFront.SetSpriteSO(sprite, Network: networked); _UIAction.IconFront.SetPaletteOfCurrentSprite(palette); } else { Logger.Log("iActionGUI Not present", Category.UI); } }
public void ProcedureToChoose(GameObject bodyPart, Action inAction, SpriteDataSO InOperationSprite, string Operation) { var Sprite = bodyPart.GetComponentInChildren <SpriteHandler>(); if (Sprite != null && Sprite.GetCurrentSpriteSO() != null) { OrganSprite.SetSpriteSO(Sprite.GetCurrentSpriteSO()); } OperationSprite.SetSpriteSO(InOperationSprite); TitleText.text = Operation + " " + bodyPart.name; ToPerform = inAction; }
/// <summary> /// Initializes plant with data another plant object /// </summary> /// <param name="_PlantData">data to copy</param> private void SetValues(PlantData _PlantData) { PlantName = _PlantData.PlantName; ProduceObject = _PlantData.ProduceObject; GrowthSpritesSOs = _PlantData.GrowthSpritesSOs; FullyGrownSpriteSO = _PlantData.FullyGrownSpriteSO; DeadSpriteSO = _PlantData.DeadSpriteSO; WeedResistance = _PlantData.WeedResistance; WeedGrowthRate = _PlantData.WeedGrowthRate; GrowthSpeed = _PlantData.GrowthSpeed; Potency = _PlantData.Potency; Endurance = _PlantData.Endurance; Yield = _PlantData.Yield; Lifespan = _PlantData.Lifespan; PlantTrays = _PlantData.PlantTrays; ReagentProduction = _PlantData.ReagentProduction; MutatesInToGameObject = _PlantData.MutatesInToGameObject; }
private void Awake() { lightControl = GetComponent <ItemLightControl>(); if (runsOutOverTime) { destroyThisComponentOnOpen = false; offSprite = spriteHandler.GetCurrentSpriteSO(); } if (glowHandler != null) { glowHandler.SetActive(false); } if (actionButton == null) { return; } actionButton.ServerActionClicked += Open; }
public void Empty(bool ClearSubCatalogue = false, bool Network = true) { if (ClearSubCatalogue) { SubCatalogue = new List <SpriteDataSO>(); } if (HasSpriteInImageComponent() == false && PresentSpriteSet == null && cataloguePage == -1) { return; } cataloguePage = -1; PushClear(false); PresentSpriteSet = null; if (Network) { NetUpdate(NewEmpty: true); } }
public void Empty(bool clearCatalogue = false, bool networked = true) { if (clearCatalogue) { SubCatalogue = new List <SpriteDataSO>(); } if (HasSpriteInImageComponent() == false && PresentSpriteSet == null && cataloguePage == -1) { return; } cataloguePage = -1; PushClear(false); PresentSpriteSet = null; OnSpriteDataSOChanged?.Invoke(null); if (networked) { NetUpdate(newEmpty: true); } }
/// <summary> /// Initializes plant with data from default plant /// </summary> /// <param name="DefaultPlantData">DefaultPlantData.plantdata's values are copied</param> private void SetValues(DefaultPlantData DefaultPlantData) { var _PlantData = DefaultPlantData.plantData; Name = _PlantData.Name; Plantname = _PlantData.Plantname; Description = _PlantData.Description; if (ProduceObject == null) { ProduceObject = _PlantData.ProduceObject; } if (GrowthSpritesSOs.Count == 0) { GrowthSpritesSOs = _PlantData.GrowthSpritesSOs; } if (FullyGrownSpriteSO == null) { FullyGrownSpriteSO = _PlantData.FullyGrownSpriteSO; } if (DeadSpriteSO == null) { DeadSpriteSO = _PlantData.DeadSpriteSO; } WeedResistance = _PlantData.WeedResistance; WeedGrowthRate = _PlantData.WeedGrowthRate; GrowthSpeed = _PlantData.GrowthSpeed; Potency = _PlantData.Potency; Endurance = _PlantData.Endurance; Yield = _PlantData.Yield; Lifespan = _PlantData.Lifespan; PlantTrays = (_PlantData.PlantTrays.Union(PlantTrays)).ToList(); MutatesInToGameObject = (_PlantData.MutatesInToGameObject.Union(MutatesInToGameObject)).ToList(); CombineReagentProduction(_PlantData.ReagentProduction); }
public void Combine(EquippedData parent) { if (SpriteEquipped != null) { SpriteEquipped = parent.SpriteEquipped; } if (SpriteInHandsLeft != null) { SpriteInHandsLeft = parent.SpriteInHandsLeft; } if (SpriteInHandsRight != null) { SpriteInHandsRight = parent.SpriteInHandsRight; } if (SpriteItemIcon != null) { SpriteItemIcon = parent.SpriteItemIcon; } }
public void SetSpriteSO(SpriteDataSO NewspriteDataSO, Color?color = null, int NewvariantIndex = -1, bool Network = true) { if (NewspriteDataSO != PresentSpriteSet) { PresentSpriteSet = NewspriteDataSO; PushTexture(Network); if (Network) { NetUpdate(NewspriteDataSO); } } if (color != null) { SetColor(color.GetValueOrDefault(Color.white), Network); } if (NewvariantIndex > -1) { ChangeSpriteVariant(NewvariantIndex, Network); } }
private void NetUpdate( SpriteDataSO NewSpriteDataSO = null, int NewVariantIndex = -1, int NewCataloguePage = -1, bool NewPushTexture = false, bool NewEmpty = false, bool NewPushClear = false, bool NewClearPallet = false, Color?NewSetColour = null, List <Color> NewPalette = null) { if (NetworkThis == false) { return; } if (SpriteHandlerManager.Instance == null) { return; } if (NetworkIdentity == null) { if (this?.gameObject == null) { return; } var NetID = SpriteHandlerManager.GetRecursivelyANetworkBehaviour(this.gameObject); if (NetID == null) { Logger.LogError("Was unable to find A NetworkBehaviour for ", Category.SpriteHandler); return; } ; NetworkIdentity = NetID.netIdentity; if (NetworkIdentity == null) { var gamename = ""; if (this?.gameObject != null) { gamename = gameObject.name; } Logger.LogError("Was unable to find A NetworkBehaviour for " + gamename, Category.SpriteHandler); } } if (CustomNetworkManager.Instance._isServer == false) { return; } SpriteHandlerManager.SpriteChange spriteChange = null; if (SpriteHandlerManager.Instance.QueueChanges.ContainsKey(this)) { spriteChange = SpriteHandlerManager.Instance.QueueChanges[this]; } else { spriteChange = SpriteHandlerManager.GetSpriteChange(); } if (NewSpriteDataSO != null) { if (NewSpriteDataSO.setID == -1) { Logger.Log("NewSpriteDataSO NO ID!" + NewSpriteDataSO.name); } if (spriteChange.Empty) { spriteChange.Empty = false; } spriteChange.PresentSpriteSet = NewSpriteDataSO.setID; } if (NewVariantIndex != -1) { spriteChange.VariantIndex = NewVariantIndex; } if (NewCataloguePage != -1) { spriteChange.CataloguePage = NewCataloguePage; } if (NewPushTexture) { if (spriteChange.PushClear) { spriteChange.PushClear = false; } spriteChange.PushTexture = NewPushTexture; } if (NewEmpty) { if (spriteChange.PresentSpriteSet != -1) { spriteChange.PresentSpriteSet = -1; } spriteChange.Empty = NewEmpty; } if (NewPushClear) { if (spriteChange.PushTexture) { spriteChange.PushTexture = false; } spriteChange.PushClear = NewPushClear; } if (NewClearPallet) { if (spriteChange.Pallet != null) { spriteChange.Pallet = null; } spriteChange.ClearPallet = NewClearPallet; } if (NewSetColour != null) { spriteChange.SetColour = NewSetColour; } if (NewPalette != null) { if (spriteChange.ClearPallet) { spriteChange.ClearPallet = false; } spriteChange.Pallet = NewPalette; } if (NetworkIdentity.netId == 0) { //Logger.Log("ID hasn't been set for " + this.transform.parent); StartCoroutine(WaitForNetInitialisation(spriteChange)); } else { SpriteHandlerManager.Instance.QueueChanges[this] = spriteChange; } }
private void SetupSprite(SpriteDataSO spriteSheetAndData, string clothesDictKey, Color?color = null) { clothes[clothesDictKey].spriteHandler.SetSpriteSO(spriteSheetAndData, color.GetValueOrDefault(Color.white)); }
public override void UpdateSpritesForImplant(BodyPart implant, ClothingHideFlags INClothingHide, SpriteDataSO Sprite, SpriteOrder _SpriteOrder = null) { ClothingHide = INClothingHide; SpriteOrder = _SpriteOrder; baseSpriteHandler.PushTexture(); OverlySpriteHandler.PushTexture(); }
public virtual void UpdateSpritesForImplant(BodyPart implant, ClothingHideFlags INClothingHide, SpriteDataSO Sprite, SpriteOrder _SpriteOrder = null) { if (baseSpriteHandler == null) { return; } ClothingHide = INClothingHide; UpdateData(JsonConvert.SerializeObject(_SpriteOrder)); //baseSpriteHandler.name = baseSpriteHandler.name + implant.name; baseSpriteHandler.SetSpriteSO(Sprite, Color.white); SpriteOrder = _SpriteOrder; if (SpriteOrder != null) { if (SpriteOrder.Orders.Count > 0) { spriteRenderer.sortingOrder = SpriteOrder.Orders[0]; } } baseSpriteHandler.ChangeSpriteVariant(referenceOffset, false); }
private void SpriteHandlerSOChanged(SpriteDataSO obj) { UIActionManager.SetSpriteSO(this, spriteHandler.GetCurrentSpriteSO(), false, spriteHandler.Palette); }