internal ImbueEffectPreset Internal_ApplyTemplate() { if (this.NewStatusID == -1) { this.NewStatusID = this.TargetStatusID; } var preset = CustomStatusEffects.CreateCustomImbue(this); SLPackManager.AddLateApplyListener(OnLateApply, preset); CustomStatusEffects.SetImbueLocalization(preset, Name, Description); // check for custom icon if (!string.IsNullOrEmpty(SLPackName) && !string.IsNullOrEmpty(SubfolderName) && SL.GetSLPack(SLPackName) is SLPack pack) { var dir = $@"{pack.GetPathForCategory<StatusCategory>()}\{SubfolderName}"; if (pack.FileExists(dir, "icon.png")) { var tex = pack.LoadTexture2D(dir, "icon.png"); var sprite = CustomTextures.CreateSprite(tex, CustomTextures.SpriteBorderTypes.NONE); preset.ImbueStatusIcon = sprite; } } return(preset); }
internal override void Internal_ApplyTemplate(StatusEffect status) { base.Internal_ApplyTemplate(status); var comp = status as LevelStatusEffect; SLPackManager.AddLateApplyListener(OnLateApply, comp); }
// ======== SL Setup ======== internal static void Setup(bool isFirstSetup = true) { var start = Time.realtimeSinceStartup; if (isFirstSetup) { CloneHolder = new GameObject("SL_CloneHolder").transform; GameObject.DontDestroyOnLoad(CloneHolder.gameObject); CloneHolder.hideFlags |= HideFlags.HideAndDontSave; CloneHolder.gameObject.SetActive(false); SLRPCManager.Setup(); PlayerSaveExtension.LoadExtensionTypes(); CheckPrefabDictionaries(); TryInvoke(BeforePacksLoaded); } else { ResetForHotReload(); } // Load SL Packs SLPackManager.LoadAllPacks(isFirstSetup); if (isFirstSetup) { foreach (var pack in SL.s_packs) { pack.Value.TryApplyItemTextureBundles(); } } // Invoke OnPacksLoaded and cleanup PacksLoaded = true; Log("SideLoader Setup Finished"); Log("-------------------------"); SL.Log("SL Setup took " + (Time.realtimeSinceStartup - start) + " seconds"); if (isFirstSetup) { if (OnPacksLoaded != null) { TryInvoke(OnPacksLoaded); Log("Finished invoking OnPacksLoaded."); } /* Setup UI */ UIManager.Init(); } }
public SLPackListView() { Instance = this; m_currentCategory = SLPackManager.GetCategoryInstance <ItemCategory>(); var list = At.GetImplementationsOf(typeof(ContentTemplate)); s_templateTypes = list.OrderBy(it => it.Name).ToList(); ConstructUI(); }
private void ConstructListView(GameObject leftPane) { var titleObj = UIFactory.CreateLabel(leftPane, TextAnchor.MiddleLeft); var titleLayout = titleObj.AddComponent <LayoutElement>(); titleLayout.minHeight = 25; var titleText = titleObj.GetComponent <Text>(); titleText.text = "SLPack Category:"; var subfolderDropObj = UIFactory.CreateDropdown(leftPane, out Dropdown subDrop); var subdropLayout = subfolderDropObj.AddComponent <LayoutElement>(); subdropLayout.minHeight = 25; var list = new List <ITemplateCategory>(); foreach (var ctg in SLPackManager.SLPackCategories) { if (ctg is ITemplateCategory category) { list.Add(category); } } list = list.OrderBy(it => it.FolderName).ToList(); subDrop.options = new List <Dropdown.OptionData>(); foreach (var entry in list) { subDrop.options.Add(new Dropdown.OptionData { text = entry.FolderName }); } var itemCtg = SLPackManager.GetCategoryInstance <ItemCategory>(); subDrop.value = list.IndexOf(itemCtg); subDrop.onValueChanged.AddListener((int val) => { m_currentCategory = list[val]; RefreshGeneratorTypeDropdown(); RefreshSLPackContentList(); }); m_scrollObj = UIFactory.CreateScrollView(leftPane, out m_pageContent, out SliderScrollbar scroller, new Color(0.1f, 0.1f, 0.1f)); }
/// <summary> /// Returns the folder path for this SLPack, plus the given SLPackCategory's FolderPath. /// </summary> /// <param name="type">The SLPackCategory type.</param> /// <returns>The path string, or null if an error was experienced.</returns> public string GetPathForCategory(Type type) { if (type == null || !typeof(SLPackCategory).IsAssignableFrom(type)) { throw new ArgumentException("type"); } var instance = SLPackManager.GetCategoryInstance(type); if (instance == null) { throw new Exception($"Trying to get folder path for '{type.FullName}', but category instance is null!"); } string ret = this.FolderPath; if (!string.IsNullOrEmpty(ret)) { ret += Path.DirectorySeparatorChar; } return($@"{ret}{instance.FolderName}"); }
public override void ApplyToItem(Item item) { base.ApplyToItem(item); SLPackManager.AddLateApplyListener(OnLateApply, item); var skill = item as Skill; if (this.Cooldown != null) { skill.Cooldown = (float)this.Cooldown; } if (this.ManaCost != null) { skill.ManaCost = (float)this.ManaCost; } if (this.StaminaCost != null) { skill.StaminaCost = (float)this.StaminaCost; } if (this.DurabilityCost != null) { skill.DurabilityCost = (float)this.DurabilityCost; } if (this.DurabilityCostPercent != null) { skill.DurabilityCostPercent = (float)this.DurabilityCostPercent; } if (this.VFXOnStart != null) { skill.VFXOnStart = (bool)this.VFXOnStart; } if (this.StopStartVFXOnEnd != null) { skill.StopVFX = (bool)this.StopStartVFXOnEnd; } if (this.HealthCost != null) { skill.HealthCost = (float)this.HealthCost; } if (this.StartVFX != null) { if (this.StartVFX == SL_PlayVFX.VFXPrefabs.NONE) { skill.StartVFX = null; } else { var prefab = SL_PlayVFX.GetVfxSystem((SL_PlayVFX.VFXPrefabs) this.StartVFX); var copy = GameObject.Instantiate(prefab); GameObject.DontDestroyOnLoad(copy); copy.SetActive(false); skill.StartVFX = copy.GetComponent <VFXSystem>(); } } if (this.RequiredPlayerType != null) { skill.RequiredPType = (PlayerSystem.PlayerTypes) this.RequiredPlayerType; } // Add to internal dictionary of custom skills (for F3 menu fix) if (s_customSkills.ContainsKey(skill.ItemID)) { s_customSkills[skill.ItemID] = skill; } else { s_customSkills.Add(skill.ItemID, skill); } }
internal virtual void Internal_ApplyTemplate(StatusEffect status) { SL.Log("Applying Status Effect template: " + Name ?? status.name); SLPackManager.AddLateApplyListener(OnLateApply, status); CustomStatusEffects.SetStatusLocalization(status, Name, Description); if (status.StatusData == null) { status.StatusData = new StatusData(); } if (Lifespan != null) { status.StatusData.LifeSpan = (float)Lifespan; } if (RefreshRate != null) { status.RefreshRate = (float)RefreshRate; } if (this.Priority != null) { At.SetField(status, "m_priority", (int)this.Priority); } if (this.Purgeable != null) { At.SetField(status, "m_purgeable", (bool)this.Purgeable); } if (this.DelayedDestroyTime != null) { status.DelayedDestroyTime = (int)this.DelayedDestroyTime; } if (BuildupRecoverySpeed != null) { status.BuildUpRecoverSpeed = (float)BuildupRecoverySpeed; } if (IgnoreBuildupIfApplied != null) { status.IgnoreBuildUpIfApplied = (bool)IgnoreBuildupIfApplied; } if (DisplayedInHUD != null) { status.DisplayInHud = (bool)DisplayedInHUD; } if (IsHidden != null) { status.IsHidden = (bool)IsHidden; } if (IsMalusEffect != null) { status.IsMalusEffect = (bool)this.IsMalusEffect; } if (this.ActionOnHit != null) { At.SetField(status, "m_actionOnHit", (StatusEffect.ActionsOnHit) this.ActionOnHit); } if (this.RemoveRequiredStatus != null) { status.RemoveRequiredStatus = (bool)this.RemoveRequiredStatus; } if (this.NormalizeDamageDisplay != null) { status.NormalizeDamageDisplay = (bool)this.NormalizeDamageDisplay; } if (this.IgnoreBarrier != null) { status.IgnoreBarrier = (bool)this.IgnoreBarrier; } if (this.StatusIdentifier != this.TargetStatusIdentifier) { At.SetField(status, "m_effectType", new TagSourceSelector(Tag.None)); } if (Tags != null) { var tagSource = CustomTags.SetTagSource(status.gameObject, Tags, true); At.SetField(status, "m_tagSource", tagSource); } else if (!status.GetComponent <TagSource>()) { var tagSource = status.gameObject.AddComponent <TagSource>(); At.SetField(status, "m_tagSource", tagSource); } if (this.PlayFXOnActivation != null) { status.PlayFXOnActivation = (bool)this.PlayFXOnActivation; } if (this.VFXInstantiationType != null) { status.FxInstantiation = (StatusEffect.FXInstantiationTypes) this.VFXInstantiationType; } if (this.VFXPrefab != null) { if (this.VFXPrefab == SL_PlayVFX.VFXPrefabs.NONE) { status.FXPrefab = null; } else { var clone = GameObject.Instantiate(SL_PlayVFX.GetVfxSystem((SL_PlayVFX.VFXPrefabs) this.VFXPrefab)); GameObject.DontDestroyOnLoad(clone); status.FXPrefab = clone.transform; } } if (this.FXOffset != null) { status.FxOffset = (Vector3)this.FXOffset; } if (this.PlaySpecialFXOnStop != null) { status.PlaySpecialFXOnStop = (bool)this.PlaySpecialFXOnStop; } // setup family if (this.FamilyMode == null && this.StatusIdentifier != this.TargetStatusIdentifier) { // Creating a new status, but no unique bind family was declared. Create one. var family = new StatusEffectFamily { Name = this.StatusIdentifier + "_FAMILY", LengthType = StatusEffectFamily.LengthTypes.Short, MaxStackCount = 1, StackBehavior = StatusEffectFamily.StackBehaviors.IndependantUnique }; At.SetField(status, "m_bindFamily", family); At.SetField(status, "m_familyMode", StatusEffect.FamilyModes.Bind); } if (this.FamilyMode == StatusEffect.FamilyModes.Bind) { At.SetField(status, "m_familyMode", StatusEffect.FamilyModes.Bind); if (this.BindFamily != null) { At.SetField(status, "m_bindFamily", this.BindFamily.CreateAsBindFamily()); } } else if (this.FamilyMode == StatusEffect.FamilyModes.Reference) { At.SetField(status, "m_familyMode", StatusEffect.FamilyModes.Reference); if (this.ReferenceFamilyUID != null) { At.SetField(status, "m_stackingFamily", new StatusEffectFamilySelector() { SelectorValue = this.ReferenceFamilyUID }); } } // check for custom icon if (!string.IsNullOrEmpty(SerializedSLPackName) && !string.IsNullOrEmpty(SerializedSubfolderName) && SL.GetSLPack(SerializedSLPackName) is SLPack pack) { var dir = $@"{pack.GetPathForCategory<StatusCategory>()}\{SerializedSubfolderName}"; if (pack.FileExists(dir, "icon.png")) { var tex = pack.LoadTexture2D(dir, "icon.png"); var sprite = CustomTextures.CreateSprite(tex, CustomTextures.SpriteBorderTypes.NONE); status.OverrideIcon = sprite; At.SetField(status, "m_defaultStatusIcon", new StatusTypeIcon(Tag.None) { Icon = sprite }); } } }
public override void ApplyToItem(Item item) { base.ApplyToItem(item); SLPackManager.AddLateApplyListener(OnLateApply, item); }