Ejemplo n.º 1
0
 // Token: 0x060030FA RID: 12538 RVA: 0x00021B47 File Offset: 0x0001FD47
 public static bool Begin(GameObject modulePrefab)
 {
     MultiplayerBuilder.Initialize();
     if (modulePrefab == null)
     {
         Debug.LogWarning("Builder : Begin() : Module prefab is null!");
         return(false);
     }
     if (modulePrefab != MultiplayerBuilder.prefab)
     {
         MultiplayerBuilder.End();
     }
     MultiplayerBuilder.prefab = modulePrefab;
     MultiplayerBuilder.Update();
     return(true);
 }
Ejemplo n.º 2
0
        // Token: 0x060030FF RID: 12543 RVA: 0x0012D7E8 File Offset: 0x0012B9E8
        public static bool TryPlace(out GameObject outObject, out Constructable outConstructable)
        {
            outObject        = null;
            outConstructable = null;

            MultiplayerBuilder.Initialize();

            if (MultiplayerBuilder.prefab == null)
            {
                return(false);
            }

            Utils.PlayEnvSound(MultiplayerBuilder.placeSound, MultiplayerBuilder.ghostModel.transform.position, 10f);
            ConstructableBase componentInParent = MultiplayerBuilder.ghostModel.GetComponentInParent <ConstructableBase>();

            if (componentInParent != null)
            {
                MultiplayerBuilder.Update();
                BaseGhost component = MultiplayerBuilder.ghostModel.GetComponent <BaseGhost>();

                component.Place();
                if (component.TargetBase != null)
                {
                    componentInParent.transform.SetParent(component.TargetBase.transform, true);
                }
                componentInParent.SetState(false, true);

                componentInParent.transform.position = overridePosition;
                componentInParent.transform.rotation = overrideRotation;

                outObject        = componentInParent.gameObject;
                outConstructable = componentInParent;
            }
            else
            {
                MultiplayerBuilder.placementTarget = GuidHelper.Find(targetGuid);

                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(MultiplayerBuilder.prefab);
                bool       flag       = false;
                bool       flag2      = false;

                SubRoot currentSub = Player.main.GetCurrentSub();
                if (currentSub != null)
                {
                    flag  = currentSub.isBase;
                    flag2 = currentSub.isCyclops;
                    gameObject.transform.parent = currentSub.GetModulesRoot();
                }
                else if (MultiplayerBuilder.placementTarget != null && MultiplayerBuilder.allowedOutside)
                {
                    SubRoot componentInParent2 = MultiplayerBuilder.placementTarget.GetComponentInParent <SubRoot>();
                    if (componentInParent2 != null)
                    {
                        gameObject.transform.parent = componentInParent2.GetModulesRoot();
                    }
                }
                Transform transform = gameObject.transform;
                transform.localPosition = overridePosition;
                transform.localRotation = overrideRotation;

                Constructable componentInParent3 = gameObject.GetComponentInParent <Constructable>();
                componentInParent3.SetState(false, true);
                Utils.SetLayerRecursively(gameObject, LayerMask.NameToLayer((!flag) ? "Interior" : "Default"), true, -1);
                if (MultiplayerBuilder.ghostModel != null)
                {
                    UnityEngine.Object.Destroy(MultiplayerBuilder.ghostModel);
                }
                componentInParent3.SetIsInside(flag || flag2);
                SkyEnvironmentChanged.Send(gameObject, currentSub);

                transform.localPosition = overridePosition;
                transform.localRotation = overrideRotation;

                outObject        = gameObject;
                outConstructable = componentInParent3;
            }
            MultiplayerBuilder.ghostModel = null;
            MultiplayerBuilder.prefab     = null;
            MultiplayerBuilder.canPlace   = false;
            return(true);
        }