From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/WeaponLoadTask.cs | 121 +++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/WeaponLoadTask.cs (limited to 'Client/Assets/Scripts/XMainClient/WeaponLoadTask.cs') diff --git a/Client/Assets/Scripts/XMainClient/WeaponLoadTask.cs b/Client/Assets/Scripts/XMainClient/WeaponLoadTask.cs new file mode 100644 index 00000000..3f5aad7e --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/WeaponLoadTask.cs @@ -0,0 +1,121 @@ +using System; +using UnityEngine; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class WeaponLoadTask : MountLoadTask + { + public XGameObject xgo2 = null; + + private static Quaternion _defaultSkinRot = Quaternion.Euler(new Vector3(-90f, 0f, 0f)); + + private static CommandCallback secondWeaponLoaded = new CommandCallback(WeaponLoadTask._SecondWeaponLoaded); + + public WeaponLoadTask(EPartType p, MountLoadCallback mountPartLoadCb) : base(p, mountPartLoadCb) + { + } + + public override void Reset(XEntity e) + { + this.processStatus = EProcessStatus.ENotProcess; + this.location = ""; + bool flag = this.xgo != null; + if (flag) + { + XRenderComponent.RemoveObj(e, this.xgo.Get()); + XGameObject.DestroyXGameObject(this.xgo); + } + this.xgo = null; + bool flag2 = this.xgo2 != null; + if (flag2) + { + XRenderComponent.RemoveObj(e, this.xgo2.Get()); + XGameObject.DestroyXGameObject(this.xgo2); + } + this.xgo2 = null; + } + + public override void ProcessEnable(bool enable, bool forceDisable, int layer) + { + base.ProcessEnable(enable, forceDisable, layer); + bool flag = this.xgo2 != null; + if (flag) + { + MountLoadTask.ProcessEnable(this.xgo2, enable, forceDisable, layer); + } + } + + public override void ProcessRenderQueue(int renderQueue) + { + base.ProcessRenderQueue(renderQueue); + bool flag = this.xgo2 != null; + if (flag) + { + MountLoadTask.ProcessRenderQueue(this.xgo2, renderQueue); + } + } + + public override void ProcessRenderComponent(XEntity e) + { + base.ProcessRenderComponent(e); + bool flag = this.xgo2 != null; + if (flag) + { + MountLoadTask.ProcessRenderComponent(this.xgo2, e); + } + } + + private static void _SecondWeaponLoaded(XGameObject gameObject, object o, int commandID) + { + XEntity xentity = o as XEntity; + int layer = xentity.DefaultLayer; + bool enable = true; + bool flag = xentity.Equipment != null; + if (flag) + { + bool isUIAvatar = xentity.Equipment.IsUIAvatar; + if (isUIAvatar) + { + layer = XQualitySetting.UILayer; + } + enable = xentity.Equipment.IsRenderEnable; + } + MountLoadTask.ProcessRender(gameObject, xentity, layer, enable, -1, false); + } + + public void PostProcess(Transform attachPoint0, Transform attachPoint1, XEntity e) + { + this.xgo.SetParentTrans(attachPoint0); + bool isSkin = base.IsSkin; + if (isSkin) + { + this.xgo.SetLocalPRS(Vector3.zero, true, WeaponLoadTask._defaultSkinRot, true, Vector3.one, true); + } + else + { + this.xgo.SetLocalPRS(Vector3.zero, true, Quaternion.identity, true, Vector3.one, true); + } + bool flag = attachPoint1 != null; + if (flag) + { + bool flag2 = this.xgo2 == null; + if (flag2) + { + this.xgo2 = XGameObject.CloneXGameObject(this.xgo, true); + this.xgo2.CallCommand(WeaponLoadTask.secondWeaponLoaded, e, -1, false); + } + this.xgo2.SetParentTrans(attachPoint1); + bool isSkin2 = base.IsSkin; + if (isSkin2) + { + this.xgo2.SetLocalPRS(Vector3.zero, true, WeaponLoadTask._defaultSkinRot, true, Vector3.one, true); + } + else + { + this.xgo2.SetLocalPRS(Vector3.zero, true, Quaternion.identity, true, Vector3.one, true); + } + } + } + } +} -- cgit v1.1-26-g67d0