using UnityEngine.Scripting; namespace GameEvent.SequenceActions { [Preserve] public class ActionOpenWindowRebirth : ActionBaseClientAction { public override void OnClientPerform(Entity target) { //Log.Out("ActionOpenWindowRebirth-OnClientPerform START"); EntityPlayer entityPlayer = target as EntityPlayer; if (entityPlayer != null) { //Log.Out("ActionOpenWindowRebirth-OnClientPerform 1"); var uiforPlayer = LocalPlayerUI.GetUIForPlayer(entityPlayer as EntityPlayerLocal); //Log.Out("ActionOpenWindowRebirth-OnClientPerform this.windowName: " + this.windowName); uiforPlayer.windowManager.Open(this.windowName, true, false, true); XUiWindowGroup xuiWindowGroup = (XUiWindowGroup)uiforPlayer.windowManager.GetWindow(this.windowName); if (xuiWindowGroup != null && this.windowName == "InformationPreview") { //Log.Out("ActionOpenWindowRebirth-OnClientPerform 2"); XUiC_PreviewInformationWindowRebirth childByType = xuiWindowGroup.Controller.GetChildByType(); if (childByType != null) { //Log.Out("ActionOpenWindowRebirth-OnClientPerform 3"); childByType.description.Text = Localization.Get(this.description); childByType.description.FontSize = this.descriptionfontsize; childByType.title.Text = Localization.Get(this.title); childByType.quest = this.quest; childByType.gameevent = this.gameevent; childByType.items = this.items; childByType.windowX = this.posX; childByType.windowY = this.posY; childByType.imageWidth = this.imageWidth; childByType.imageHeight = this.imageHeight; //Log.Out("ActionOpenWindowRebirth-OnClientPerform childByType.description.Text: " + childByType.description.Text); //Log.Out("ActionOpenWindowRebirth-OnClientPerform childByType.title.Text: " + childByType.title.Text); //Log.Out("ActionOpenWindowRebirth-OnClientPerform childByType.windowX: " + childByType.windowX); //Log.Out("ActionOpenWindowRebirth-OnClientPerform childByType.windowY: " + childByType.windowY); if (this.previewIndex != -1) { //Log.Out("ActionOpenWindowRebirth-OnClientPerform this.previewIndex: " + this.previewIndex); childByType.previewIndex = this.previewIndex; if (childByType.previewIndex == 999) { //childByType.gameevent = "meet_purge"; //Log.Out("ActionOpenWindowRebirth-OnClientPerform 4"); } else { //Log.Out("ActionOpenWindowRebirth-OnClientPerform 5"); PrefabInstance poiatPosition = RebirthUtilities.GetPrefabAtPosition(entityPlayer.position); // entityPlayer.world.GetPOIAtPosition(entityPlayer.position, false); //Log.Out("ActionOpenWindowRebirth-OnClientPerform poiatPosition.name: " + poiatPosition.name); if (poiatPosition != null) { string[] parts = poiatPosition.name.Split('.'); string strPrefabName = parts[0].ToLower(); int previewIndex = this.previewIndex; if (strPrefabName == "trader_joel") { if (previewIndex == 0 || previewIndex == 4) { childByType.description.Text = childByType.description.Text + "\n\n - [b789f0]Joel[-]"; childByType.trader = "joel"; } else if (previewIndex == 1) { childByType.title.Text = Localization.Get("meet_isaac_title"); image = "isaac"; childByType.description.Text = childByType.description.Text.Replace("{0}", "[8bd984]Isaac[-]"); childByType.description.Text = childByType.description.Text.Replace("{1}", "He"); } } else if (strPrefabName == "trader_rekt") { if (previewIndex == 0 || previewIndex == 4) { childByType.description.Text = childByType.description.Text + "\n\n - [b789f0]Rekt[-]"; childByType.trader = "rekt"; } else if (previewIndex == 1) { childByType.title.Text = Localization.Get("meet_elias_title"); image = "elias"; childByType.description.Text = childByType.description.Text.Replace("{0}", "[8bd984]Elias[-]"); childByType.description.Text = childByType.description.Text.Replace("{1}", "He"); } } else if (strPrefabName == "trader_jen") { if (previewIndex == 0 || previewIndex == 4) { childByType.description.Text = childByType.description.Text + "\n\n - [b789f0]Jen[-]"; childByType.trader = "jen"; } else if (previewIndex == 1) { childByType.title.Text = Localization.Get("meet_scarlett_title"); image = "scarlett"; childByType.description.Text = childByType.description.Text.Replace("{0}", "[8bd984]Scarlett[-]"); childByType.description.Text = childByType.description.Text.Replace("{1}", "She"); } } else if (strPrefabName == "trader_hugh") { if (previewIndex == 0 || previewIndex == 4) { childByType.description.Text = childByType.description.Text + "\n\n - [b789f0]Hugh[-]"; childByType.trader = "hugh"; } else if (previewIndex == 1) { childByType.title.Text = Localization.Get("meet_helen_title"); image = "helen"; childByType.description.Text = childByType.description.Text.Replace("{0}", "[8bd984]Helen[-]"); childByType.description.Text = childByType.description.Text.Replace("{1}", "She"); } } else if (strPrefabName == "trader_bob") { if (previewIndex == 0 || previewIndex == 4) { childByType.description.Text = childByType.description.Text + "\n\n - [b789f0]Bob[-]"; childByType.trader = "bob"; } else if (previewIndex == 1) { childByType.title.Text = Localization.Get("meet_liam_title"); image = "liam"; childByType.description.Text = childByType.description.Text.Replace("{0}", "[8bd984]Liam[-]"); childByType.description.Text = childByType.description.Text.Replace("{1}", "He"); } } if (previewIndex == 4) { childByType.gameevent = "meet_" + childByType.trader; } } } } childByType.imagePreview.SpriteName = this.image; } } } } public override void ParseProperties(DynamicProperties properties) { base.ParseProperties(properties); properties.ParseString(ActionOpenWindowRebirth.PropWindowName, ref this.windowName); properties.ParseString(ActionOpenWindowRebirth.PropDescription, ref this.description); properties.ParseInt(ActionOpenWindowRebirth.PropDescriptionFontSize, ref this.descriptionfontsize); properties.ParseInt(ActionOpenWindowRebirth.PropPosX, ref this.posX); properties.ParseInt(ActionOpenWindowRebirth.PropPosY, ref this.posY); properties.ParseInt(ActionOpenWindowRebirth.PropImageWidth, ref this.imageWidth); properties.ParseInt(ActionOpenWindowRebirth.PropImageHeight, ref this.imageHeight); properties.ParseString(ActionOpenWindowRebirth.PropImage, ref this.image); properties.ParseString(ActionOpenWindowRebirth.PropTitle, ref this.title); properties.ParseString(ActionOpenWindowRebirth.PropQuest, ref this.quest); properties.ParseString(ActionOpenWindowRebirth.PropGameEvent, ref this.gameevent); properties.ParseString(ActionOpenWindowRebirth.PropItems, ref this.items); properties.ParseInt(ActionOpenWindowRebirth.PropPreviewIndex, ref this.previewIndex); } public override BaseAction CloneChildSettings() { return new ActionOpenWindowRebirth { targetGroup = this.targetGroup, windowName = this.windowName, description = this.description, descriptionfontsize = this.descriptionfontsize, posX = this.posX, posY = this.posY, imageWidth = this.imageWidth, imageHeight = this.imageHeight, image = this.image, title = this.title, items = this.items, previewIndex = this.previewIndex, gameevent = this.gameevent, quest = this.quest }; } protected string windowName = ""; protected string description = ""; protected int descriptionfontsize = 30; protected int descriptionPosY = 0; protected string image = ""; protected string title = ""; protected string quest = ""; protected string gameevent = ""; protected string items = ""; protected int previewIndex = -1; protected int posX = 0; protected int posY = 0; protected int imageWidth = 0; protected int imageHeight = 0; protected static string PropWindowName = "window_name"; protected static string PropDescription = "description"; protected static string PropDescriptionFontSize = "description_font_size"; protected static string PropPosX = "posX"; protected static string PropPosY = "posY"; protected static string PropImageWidth = "imageWidth"; protected static string PropImageHeight = "imageHeight"; protected static string PropImage = "image"; protected static string PropTitle = "title"; protected static string PropQuest = "quest"; protected static string PropGameEvent = "gameevent"; protected static string PropItems = "items"; protected static string PropPreviewIndex = "previewIndex"; } }