コード例 #1
0
 /// <summary>
 /// Force this WhooshPoint to play its effect
 /// </summary>
 public static void Play(this WhooshPoint point)
 {
     if ((Utils.GetInstanceField(point, "trigger") is WhooshPoint.Trigger trigger) && trigger != WhooshPoint.Trigger.OnGrab && Utils.GetInstanceField(point, "effectInstance") != null)
     {
         (Utils.GetInstanceField(point, "effectInstance") as EffectInstance)?.Play();
     }
     Utils.SetInstanceField(point, "effectActive", true);
     Utils.SetInstanceField(point, "dampenedIntensity", 0);
 }
コード例 #2
0
        protected virtual void OnValidate()
        {
            if (!gameObject.activeInHierarchy)
            {
                return;
            }
            holderPoint = transform.Find("HolderPoint");
            if (!holderPoint)
            {
                holderPoint = new GameObject("HolderPoint").transform;
                holderPoint.SetParent(transform, false);
            }
            parryPoint = transform.Find("ParryPoint");
            if (!parryPoint)
            {
                parryPoint = new GameObject("ParryPoint").transform;
                parryPoint.SetParent(transform, false);
            }
            preview = GetComponentInChildren <Preview>();
            if (!preview && transform.Find("Preview"))
            {
                preview = transform.Find("Preview").gameObject.AddComponent <Preview>();
            }
            if (!preview)
            {
                preview = new GameObject("Preview").AddComponent <Preview>();
                preview.transform.SetParent(transform, false);
            }
            whoosh = GetComponentInChildren <WhooshPoint>();
            if (!whoosh && transform.Find("Whoosh"))
            {
                whoosh = transform.Find("Whoosh").gameObject.AddComponent <WhooshPoint>();
            }
            if (!whoosh)
            {
                whoosh = new GameObject("Whoosh").AddComponent <WhooshPoint>();
                whoosh.transform.SetParent(transform, false);
            }

            foreach (MeshRenderer mesh in GetComponentsInChildren <MeshRenderer>())
            {
                if (!mesh.GetComponent <Paintable>())
                {
                    mesh.gameObject.AddComponent <Paintable>();
                }
            }

            if (!mainHandleRight)
            {
                foreach (HandleDefinition handleDefinition in GetComponentsInChildren <HandleDefinition>())
                {
                    if (handleDefinition.IsAllowed(Side.Right))
                    {
                        mainHandleRight = handleDefinition;
                        break;
                    }
                }
            }
            if (!mainHandleLeft)
            {
                foreach (HandleDefinition handleDefinition in GetComponentsInChildren <HandleDefinition>())
                {
                    if (handleDefinition.IsAllowed(Side.Left))
                    {
                        mainHandleLeft = handleDefinition;
                        break;
                    }
                }
            }
            if (!mainHandleRight)
            {
                mainHandleRight = GetComponentInChildren <HandleDefinition>();
            }
            if (useCustomCenterOfMass)
            {
                GetComponent <Rigidbody>().centerOfMass = customCenterOfMass;
            }
            else
            {
                GetComponent <Rigidbody>().ResetCenterOfMass();
            }
            if (customInertiaTensor)
            {
                if (customInertiaTensorCollider == null)
                {
                    Transform foundInertiaTensor = GetComponentInParent <ItemDefinition>().transform.Find("InertiaTensorCollider");
                    if (foundInertiaTensor)
                    {
                        customInertiaTensorCollider = foundInertiaTensor.GetComponent <CapsuleCollider>();
                    }
                }
                if (customInertiaTensorCollider == null)
                {
                    customInertiaTensorCollider = new GameObject("InertiaTensorCollider").AddComponent <CapsuleCollider>();
                    customInertiaTensorCollider.transform.SetParent(transform, false);
                    customInertiaTensorCollider.radius    = 0.05f;
                    customInertiaTensorCollider.direction = 2;
                }
                customInertiaTensorCollider.enabled          = false;
                customInertiaTensorCollider.isTrigger        = true;
                customInertiaTensorCollider.gameObject.layer = 2;
            }
            else
            {
                customInertiaTensorCollider = null;
            }
        }