Example #1
0
        private void OnPlaced()
        {
            base.enabled = false;
            Transform child = this._ghosts[this._currentGhost]._go.transform.GetChild(0);

            if (!BoltNetwork.isRunning)
            {
                if (LocalPlayer.Create.BuildingPlacer.LastHit != null && LocalPlayer.Create.BuildingPlacer.LastHit.Value.transform.GetComponentInParent <BoltEntity>())
                {
                    child.parent = LocalPlayer.Create.BuildingPlacer.LastHit.Value.transform.GetComponentInParent <BoltEntity>().transform;
                }
                else
                {
                    child.parent = null;
                }
                child.SendMessage("OnPlaced", SendMessageOptions.DontRequireReceiver);
                GameObject gameObject = child.Find("Trigger").gameObject;
                gameObject.SetActive(true);
                if (this._ghosts[this._currentGhost]._initialize)
                {
                    gameObject.GetComponent <Craft_Structure>().Initialize();
                }
                UnityEngine.Object.Destroy(base.gameObject);
            }
            else
            {
                CoopConstructionEx component = child.GetComponent <CoopConstructionEx>();
                if (component)
                {
                    BoltEntity component2   = child.GetComponent <BoltEntity>();
                    BoltEntity parentEntity = LocalPlayer.Create.GetParentEntity(child.gameObject);
                    component.SendMessage("OnSerializing");
                    CoopConstructionExToken coopConstructionExToken = LocalPlayer.Create.GetCoopConstructionExToken(component, parentEntity);
                    PlaceFoundationEx       placeFoundationEx       = PlaceFoundationEx.Create(GlobalTargets.OnlyServer);
                    placeFoundationEx.Parent   = parentEntity;
                    placeFoundationEx.Position = child.transform.position;
                    placeFoundationEx.Prefab   = component2.prefabId;
                    placeFoundationEx.Token    = coopConstructionExToken;
                    placeFoundationEx.Send();
                }
                else
                {
                    PlaceConstruction placeConstruction = PlaceConstruction.Create(GlobalTargets.OnlyServer);
                    if (LocalPlayer.Create.BuildingPlacer.LastHit != null)
                    {
                        placeConstruction.Parent = LocalPlayer.Create.BuildingPlacer.LastHit.Value.transform.GetComponentInParent <BoltEntity>();
                    }
                    placeConstruction.PrefabId = child.GetComponent <BoltEntity>().prefabId;
                    placeConstruction.Position = child.position;
                    placeConstruction.Rotation = child.rotation;
                    FoundationArchitect component3 = child.GetComponent <FoundationArchitect>();
                    if (component3)
                    {
                        placeConstruction.AboveGround = component3._aboveGround;
                    }
                    placeConstruction.Send();
                }
                UnityEngine.Object.Destroy(base.gameObject, 0.05f);
            }
        }
Example #2
0
    public override void OnEvent(PlaceFoundationEx evnt)
    {
        BoltEntity boltEntity = BoltNetwork.Instantiate(evnt.Prefab, evnt.Token);

        boltEntity.transform.position = evnt.Position;
        if (evnt.Parent)
        {
            boltEntity.transform.parent = evnt.Parent.transform;
        }
        LocalPlayer.Create.RefreshGrabber();
    }
Example #3
0
        private void OnPlaced()
        {
            base.enabled = false;
            Transform child;

            if (this._inWaterGo.activeSelf)
            {
                child = this._inWaterGo.transform.GetChild(0);
            }
            else
            {
                child = this._outWaterGo.transform.GetChild(0);
            }
            if (!BoltNetwork.isRunning)
            {
                if (LocalPlayer.Create.BuildingPlacer.LastHit != null && LocalPlayer.Create.BuildingPlacer.LastHit.Value.transform.GetComponentInParent <BoltEntity>())
                {
                    child.parent = LocalPlayer.Create.BuildingPlacer.LastHit.Value.transform.GetComponentInParent <BoltEntity>().transform;
                }
                else if (LocalPlayer.Create.ParentEntity)
                {
                    DynamicBuilding component = LocalPlayer.Create.ParentEntity.GetComponent <DynamicBuilding>();
                    child.transform.parent = ((!component || !component._parentOverride) ? LocalPlayer.Create.ParentEntity.transform : component._parentOverride);
                }
                else
                {
                    child.parent = null;
                }
                child.SendMessage("OnPlaced", SendMessageOptions.DontRequireReceiver);
                GameObject gameObject = child.Find("Trigger").gameObject;
                gameObject.SetActive(true);
                if ((this._inWaterGo.activeSelf && this._initializeOutWater) || (this._outWaterGo.activeSelf && this._initializeInWater))
                {
                    gameObject.GetComponent <Craft_Structure>().Initialize();
                }
                UnityEngine.Object.Destroy(base.gameObject);
            }
            else
            {
                CoopConstructionEx component2 = child.GetComponent <CoopConstructionEx>();
                if (component2)
                {
                    BoltEntity component3 = child.GetComponent <BoltEntity>();
                    BoltEntity boltEntity = LocalPlayer.Create.GetParentEntity(child.gameObject) ?? LocalPlayer.Create.ParentEntity;
                    component2.SendMessage("OnSerializing");
                    CoopConstructionExToken coopConstructionExToken = LocalPlayer.Create.GetCoopConstructionExToken(component2, boltEntity);
                    PlaceFoundationEx       placeFoundationEx       = PlaceFoundationEx.Create(GlobalTargets.OnlyServer);
                    placeFoundationEx.Parent   = boltEntity;
                    placeFoundationEx.Position = child.transform.position;
                    placeFoundationEx.Prefab   = component3.prefabId;
                    placeFoundationEx.Token    = coopConstructionExToken;
                    placeFoundationEx.Send();
                }
                else
                {
                    PlaceConstruction placeConstruction = PlaceConstruction.Create(GlobalTargets.OnlyServer);
                    if (LocalPlayer.Create.BuildingPlacer.LastHit != null)
                    {
                        placeConstruction.Parent = LocalPlayer.Create.BuildingPlacer.LastHit.Value.transform.GetComponentInParent <BoltEntity>();
                    }
                    placeConstruction.PrefabId = child.GetComponent <BoltEntity>().prefabId;
                    placeConstruction.Position = child.position;
                    placeConstruction.Rotation = child.rotation;
                    FoundationArchitect component4 = child.GetComponent <FoundationArchitect>();
                    if (component4)
                    {
                        placeConstruction.AboveGround = component4._aboveGround;
                    }
                    placeConstruction.Send();
                }
                UnityEngine.Object.Destroy(base.gameObject, 0.05f);
            }
        }
Example #4
0
        private IEnumerator PlaceGhostRoutine(bool chain)
        {
            BuildingTypes bType = this.CurrentBlueprint._type;

            yield return(null);

            if (this.CreateMode)
            {
                this.ShownPlace = false;
                this.CreateMode = false;
                if (!this.ToolsShown)
                {
                    base.SendMessage("BuildToolsTut");
                    this.ToolsShown = true;
                }
                TreeStructure ts = this._currentGhost.GetComponentInChildren <TreeStructure>();
                if (ts && this.TargetTree)
                {
                    if (this.TargetTree.CompareTag("conTree"))
                    {
                        ts.TreeId = this.TargetTree.parent.GetComponent <TreeHealth>().LodTree.GetComponentInChildren <CoopTreeId>().Id;
                    }
                    else
                    {
                        ts.TreeId = this.TargetTree.GetComponent <TreeHealth>().LodTree.GetComponentInChildren <CoopTreeId>().Id;
                    }
                    ts.enabled = true;
                    if (!BoltNetwork.isRunning)
                    {
                        Scene.ActiveMB.StartCoroutine(ts.OnDeserialized());
                    }
                }
                CoopConstructionEx     coopEx            = this._currentGhost.GetComponent <CoopConstructionEx>();
                WallArchitect          wallArch          = this.CurrentGhost.GetComponent <WallArchitect>();
                ICoopTokenConstruction tokenConstruction = this._currentGhost.GetComponent <ICoopTokenConstruction>();
                this.ParentEntity = this.GetParentEntity(this._currentGhost);
                if (BoltNetwork.isRunning && !wallArch)
                {
                    BoltEntity component = this._currentGhost.GetComponent <BoltEntity>();
                    if (tokenConstruction != null)
                    {
                        PlaceFoundationEx placeFoundationEx = PlaceFoundationEx.Create(GlobalTargets.OnlyServer);
                        placeFoundationEx.Position = this._currentGhost.transform.position;
                        placeFoundationEx.Rotation = this._currentGhost.transform.rotation;
                        placeFoundationEx.Prefab   = component.prefabId;
                        placeFoundationEx.Token    = tokenConstruction.CustomToken;
                        placeFoundationEx.Parent   = this.ParentEntity;
                        placeFoundationEx.Send();
                        UnityEngine.Object.Destroy(this._currentGhost);
                    }
                    else if (coopEx)
                    {
                        coopEx.SendMessage("OnSerializing");
                        CoopConstructionExToken coopConstructionExToken = this.GetCoopConstructionExToken(coopEx, this.ParentEntity);
                        PlaceFoundationEx       placeFoundationEx2      = PlaceFoundationEx.Create(GlobalTargets.OnlyServer);
                        placeFoundationEx2.Parent   = this.ParentEntity;
                        placeFoundationEx2.Position = this._currentGhost.transform.position;
                        placeFoundationEx2.Rotation = this._currentGhost.transform.rotation;
                        placeFoundationEx2.Prefab   = component.prefabId;
                        placeFoundationEx2.Token    = coopConstructionExToken;
                        placeFoundationEx2.Send();
                        UnityEngine.Object.Destroy(this._currentGhost);
                    }
                    else if (!this._currentGhost.GetComponent(typeof(IAnchorableStructure)) && component)
                    {
                        this._currentGhost.AddComponent <CoopDestroyPredictedGhost>();
                        this._currentGhost.AddComponent <destroyAfter>().destroyTime = 2f;
                        PlaceConstruction placeConstruction = PlaceConstruction.Create(GlobalTargets.OnlyServer);
                        placeConstruction.Parent   = this.ParentEntity;
                        placeConstruction.PrefabId = component.prefabId;
                        placeConstruction.Position = this._currentGhost.transform.position;
                        placeConstruction.Rotation = this._currentGhost.transform.rotation;
                        if (ts)
                        {
                            placeConstruction.TreeIndex = ts.TreeId;
                        }
                        placeConstruction.Send();
                        this._currentGhost.SendMessage("OnPlacingRemotely", SendMessageOptions.DontRequireReceiver);
                    }
                    else
                    {
                        this._currentGhost.SendMessage("OnPlaced", false, SendMessageOptions.DontRequireReceiver);
                    }
                }
                else
                {
                    this._currentGhost.SendMessage("OnPlaced", false, SendMessageOptions.DontRequireReceiver);
                    this._currentGhost.transform.Find("Trigger").gameObject.SetActive(true);
                    Transform transform = this._currentGhost.transform.Find("LastBuiltLocation");
                    if (transform)
                    {
                        transform.gameObject.SetActive(true);
                    }
                    if (this.ParentEntity)
                    {
                        DynamicBuilding component2 = this.ParentEntity.GetComponent <DynamicBuilding>();
                        this._currentGhost.transform.parent = ((!component2 || !component2._parentOverride) ? this.ParentEntity.transform : component2._parentOverride);
                    }
                }
                this.ClearReferences(!chain);
                LocalPlayer.Sfx.PlayPlaceGhost();
                this.RefreshGrabber();
                yield return(YieldPresets.WaitPointFiveSeconds);

                if (chain)
                {
                    this.MultiPlaceAction(bType);
                }
            }
            yield break;
        }
 public override void OnEvent(PlaceFoundationEx evnt)
 {
     BoltEntity boltEntity = BoltNetwork.Instantiate(evnt.Prefab, evnt.Token);
     boltEntity.transform.position = evnt.Position;
     if (evnt.Parent)
     {
         boltEntity.transform.parent = evnt.Parent.transform;
     }
     LocalPlayer.Create.RefreshGrabber();
 }