internal static void Prepare(GameObject target, Container template, Vector3 referencePoint)
        {
            RepairableContainer repairable = GetOrCreateComponent <RepairableContainer>(target);

            repairable.Template        = template.gameObject;
            repairable.ParentContainer = GetParent(repairable.Template);
            repairable.TargetPosition  = RepairableContainer.GetTargetPosition(repairable.ParentContainer, referencePoint);
            repairable.TargetRotation  = Quaternion.identity;
            repairable.RequiresTools   = target.CompareTag("Metal");

            GetOrCreateComponent <BoxCollider>(target);

            target.layer = vp_Layer.Container;
        }
Exemple #2
0
        private static void RestoreRepairedContainer(RepairedContainer repairedContainer)
        {
            GameObject target = FindGameObject(repairedContainer.path, repairedContainer.position);

            if (target == null)
            {
                return;
            }

            RepairableContainer repairableContainer = target.GetComponentInChildren <RepairableContainer>();

            if (repairableContainer != null && !repairableContainer.Applied)
            {
                repairableContainer.ContainerGuid = repairedContainer.guid;
                repairableContainer.Repair();
            }
        }
        internal static void Prepare(GameObject target, Container template, Vector3 referencePoint)
        {
            if (target.GetComponent <RepairableContainer>() != null)
            {
                return;
            }

            RepairableContainer repairable = target.AddComponent <RepairableContainer>();

            repairable.Template        = GetParent(template);
            repairable.ParentContainer = GetParent(repairable.Template);
            repairable.TargetPosition  = RepairableContainer.GetTargetPosition(repairable.ParentContainer, referencePoint);
            repairable.TargetRotation  = repairable.Template.transform.localRotation;
            repairable.RequiresTools   = true;

            if (target.GetComponent <Collider>() == null)
            {
                target.AddComponent <BoxCollider>();
            }

            target.layer = vp_Layer.Container;
        }