Beispiel #1
0
 private void SpawnGate(Vector3 p1, Vector3 p2, WallChunkArchitect.Additions addition, float height)
 {
     if (BoltNetwork.isRunning)
     {
         PlaceWallChunk     placeWallChunk     = PlaceWallChunk.Create(GlobalTargets.OnlyServer);
         CoopWallChunkToken coopWallChunkToken = new CoopWallChunkToken();
         coopWallChunkToken.P1 = p1;
         coopWallChunkToken.P2 = p2;
         coopWallChunkToken.PointsPositions = null;
         coopWallChunkToken.Additions       = addition;
         coopWallChunkToken.Height          = height;
         placeWallChunk.parent  = ((!base.transform.parent) ? base.transform.GetComponentInParent <BoltEntity>() : base.transform.parent.GetComponentInParent <BoltEntity>());
         placeWallChunk.token   = coopWallChunkToken;
         placeWallChunk.prefab  = Prefabs.Instance.WallDefensiveGateGhostPrefab.GetComponent <BoltEntity>().prefabId;
         placeWallChunk.support = null;
         placeWallChunk.Send();
     }
     else
     {
         WallDefensiveGateArchitect wallDefensiveGateArchitect = UnityEngine.Object.Instantiate <WallDefensiveGateArchitect>(Prefabs.Instance.WallDefensiveGateGhostPrefab, p1, Quaternion.LookRotation(p2 - p1));
         wallDefensiveGateArchitect.P1               = p1;
         wallDefensiveGateArchitect.P2               = p2;
         wallDefensiveGateArchitect.Addition         = addition;
         wallDefensiveGateArchitect.transform.parent = base.transform.parent;
     }
 }
    public override void Attached()
    {
        CoopWallChunkToken coopWallChunkToken = (CoopWallChunkToken)this.entity.attachToken;
        WallChunkArchitect component          = base.GetComponent <WallChunkArchitect>();

        component.transform.position = coopWallChunkToken.P1;
        component.transform.LookAt(coopWallChunkToken.P2);
        component.P1                  = coopWallChunkToken.P1;
        component.P2                  = coopWallChunkToken.P2;
        component.Addition            = coopWallChunkToken.Additions;
        component.MultipointPositions = ((coopWallChunkToken.PointsPositions == null) ? null : coopWallChunkToken.PointsPositions.ToList <Vector3>());
        component.WasBuilt            = true;
        if (coopWallChunkToken.Support != null)
        {
            component.CurrentSupport = (coopWallChunkToken.Support.GetComponentInChildren(typeof(IStructureSupport)) as IStructureSupport);
        }
        if (!this.entity.isOwner)
        {
            this.entity.SendMessage("OnDeserialized");
        }
    }
Beispiel #3
0
    public override void Attached()
    {
        CoopWallChunkToken coopWallChunkToken = (CoopWallChunkToken)this.entity.attachToken;
        WallChunkArchitect component          = base.GetComponent <WallChunkArchitect>();

        component.transform.position = coopWallChunkToken.P1;
        component.transform.LookAt(coopWallChunkToken.P2);
        component.P1 = coopWallChunkToken.P1;
        component.P2 = coopWallChunkToken.P2;
        if (BoltNetwork.isServer)
        {
            base.state.Addition          = (int)component.Addition;
            coopWallChunkToken.Additions = component.Addition;
        }
        else
        {
            component.Addition = coopWallChunkToken.Additions;
        }
        component.WasPlaced           = true;
        component.MultipointPositions = ((coopWallChunkToken.PointsPositions == null) ? null : coopWallChunkToken.PointsPositions.ToList <Vector3>());
        base.state.AddCallback("Addition", new PropertyCallbackSimple(this.AdditionChanged));
        this.entity.SendMessage("OnDeserialized");
    }
Beispiel #4
0
        private IEnumerator OnPlaced()
        {
            base.enabled = false;
            yield return(null);

            if (!this._autofillmode && this.CanLock && this._multiPointsPositions.Last <Vector3>() != this._multiPointsPositions.First <Vector3>())
            {
                this.LockCurrentPoint();
            }
            if (Scene.HudGui)
            {
                Scene.HudGui.WallConstructionIcons.Shutdown();
            }
            if (this._tmpEdge != null && this._tmpEdge._root)
            {
                this._tmpEdge._root.parent = null;
                UnityEngine.Object.Destroy(this._tmpEdge._root.gameObject);
            }
            LocalPlayer.Create.Grabber.ClosePlace();
            int   chunkCount  = 0;
            float lengthCount = 0f;

            for (int i = 0; i < this._edges.Count; i++)
            {
                WallArchitect.Edge edge = this._edges[i];
                float height            = (!this._autofillmode) ? edge._height : this._currentHeight;
                lengthCount += edge._hlength;
                for (int j = 0; j < edge._segments.Length; j++)
                {
                    WallArchitect.HorizontalSegment horizontalSegment = edge._segments[j];
                    if (this.CheckForDoubledUpGhost(horizontalSegment))
                    {
                        IStructureSupport segmentSupport = this.GetSegmentSupport(horizontalSegment);
                        if (BoltNetwork.isRunning)
                        {
                            PlaceWallChunk     placeWallChunk     = PlaceWallChunk.Create(GlobalTargets.OnlyServer);
                            CoopWallChunkToken coopWallChunkToken = new CoopWallChunkToken();
                            coopWallChunkToken.P1 = horizontalSegment._p1;
                            coopWallChunkToken.P2 = horizontalSegment._p2;
                            coopWallChunkToken.PointsPositions = this.MultiPointsPositions.ToArray();
                            coopWallChunkToken.Additions       = WallChunkArchitect.Additions.Wall;
                            coopWallChunkToken.Height          = height;
                            placeWallChunk.parent  = ((segmentSupport == null) ? base.transform.GetComponentInParent <BoltEntity>() : (segmentSupport as Component).GetComponentInParent <BoltEntity>());
                            placeWallChunk.token   = coopWallChunkToken;
                            placeWallChunk.prefab  = this.ChunkPrefab.GetComponent <BoltEntity>().prefabId;
                            placeWallChunk.support = null;
                            placeWallChunk.Send();
                        }
                        else
                        {
                            WallChunkArchitect wallChunkArchitect = UnityEngine.Object.Instantiate <WallChunkArchitect>(this.ChunkPrefab);
                            wallChunkArchitect.transform.parent   = ((segmentSupport == null) ? base.transform.parent : (segmentSupport as Component).transform);
                            wallChunkArchitect.transform.position = horizontalSegment._p1;
                            wallChunkArchitect.transform.LookAt(horizontalSegment._p2);
                            wallChunkArchitect.MultipointPositions = this._multiPointsPositions;
                            wallChunkArchitect.P1             = horizontalSegment._p1;
                            wallChunkArchitect.P2             = horizontalSegment._p2;
                            wallChunkArchitect.CurrentSupport = segmentSupport;
                            wallChunkArchitect.Height         = height;
                        }
                        chunkCount++;
                    }
                }
            }
            if (!base.GetType().IsSubclassOf(typeof(WallArchitect)))
            {
                EventRegistry.Achievements.Publish(TfEvent.Achievements.PlacedWall, Mathf.FloorToInt(lengthCount));
            }
            if (!BoltNetwork.isRunning)
            {
                yield return(null);

                yield return(null);

                yield return(null);

                yield return(null);

                UnityEngine.Object.Destroy(base.gameObject);
            }
            else
            {
                CoopDestroyPredictedGhost coopDestroyPredictedGhost = base.gameObject.AddComponent <CoopDestroyPredictedGhost>();
                coopDestroyPredictedGhost.count = (float)chunkCount;
                coopDestroyPredictedGhost.delay = 0.005f;
                base.gameObject.AddComponent <destroyAfter>().destroyTime = 2f;
            }
            yield break;
        }
Beispiel #5
0
        private void ToggleBackToWall()
        {
            WallDefensiveGateArchitect component = base.GetComponent <WallDefensiveGateArchitect>();

            if (component.WasBuilt)
            {
                UnityEngine.Object.Destroy(this);
            }
            else
            {
                bool    is2Sided = component.Is2Sided;
                Vector3 vector   = (!is2Sided) ? component.P2 : Vector3.Lerp(component.P1, component.P2, 0.5f);
                if (BoltNetwork.isRunning)
                {
                    PrefabId           prefabId           = Prefabs.Instance.WallDefensiveChunkGhostPrefab.GetComponent <BoltEntity>().prefabId;
                    PlaceWallChunk     placeWallChunk     = PlaceWallChunk.Create(GlobalTargets.OnlyServer);
                    CoopWallChunkToken coopWallChunkToken = new CoopWallChunkToken();
                    coopWallChunkToken.P1 = component.P1;
                    coopWallChunkToken.P2 = vector;
                    coopWallChunkToken.PointsPositions = null;
                    coopWallChunkToken.Additions       = WallChunkArchitect.Additions.Wall;
                    coopWallChunkToken.Height          = component.Height;
                    placeWallChunk.parent  = ((!base.transform.parent) ? null : base.transform.parent.GetComponentInParent <BoltEntity>());
                    placeWallChunk.token   = coopWallChunkToken;
                    placeWallChunk.prefab  = prefabId;
                    placeWallChunk.support = null;
                    placeWallChunk.Send();
                    if (is2Sided)
                    {
                        PlaceWallChunk     placeWallChunk2     = PlaceWallChunk.Create(GlobalTargets.OnlyServer);
                        CoopWallChunkToken coopWallChunkToken2 = new CoopWallChunkToken();
                        coopWallChunkToken2.P1 = vector;
                        coopWallChunkToken2.P2 = component.P2;
                        coopWallChunkToken2.PointsPositions = null;
                        coopWallChunkToken2.Additions       = WallChunkArchitect.Additions.Wall;
                        coopWallChunkToken2.Height          = component.Height;
                        placeWallChunk2.parent  = ((!base.transform.parent) ? null : base.transform.parent.GetComponentInParent <BoltEntity>());
                        placeWallChunk2.token   = coopWallChunkToken2;
                        placeWallChunk2.prefab  = prefabId;
                        placeWallChunk2.support = null;
                        placeWallChunk2.Send();
                    }
                }
                else
                {
                    WallChunkArchitect wallChunkArchitect = UnityEngine.Object.Instantiate <WallDefensiveChunkArchitect>(Prefabs.Instance.WallDefensiveChunkGhostPrefab);
                    if (base.transform.parent)
                    {
                        wallChunkArchitect.transform.parent = base.transform.parent;
                    }
                    wallChunkArchitect.transform.position = component.P1;
                    wallChunkArchitect.transform.LookAt(vector);
                    wallChunkArchitect.MultipointPositions = null;
                    wallChunkArchitect.P1             = component.P1;
                    wallChunkArchitect.P2             = vector;
                    wallChunkArchitect.CurrentSupport = component.CurrentSupport;
                    wallChunkArchitect.Height         = component.Height;
                    if (is2Sided)
                    {
                        WallChunkArchitect wallChunkArchitect2 = UnityEngine.Object.Instantiate <WallDefensiveChunkArchitect>(Prefabs.Instance.WallDefensiveChunkGhostPrefab);
                        if (base.transform.parent)
                        {
                            wallChunkArchitect2.transform.parent = base.transform.parent;
                        }
                        wallChunkArchitect2.transform.position = vector;
                        wallChunkArchitect2.transform.LookAt(component.P2);
                        wallChunkArchitect2.MultipointPositions = null;
                        wallChunkArchitect2.P1             = vector;
                        wallChunkArchitect2.P2             = component.P2;
                        wallChunkArchitect2.CurrentSupport = component.CurrentSupport;
                    }
                }
                base.StartCoroutine(this.DelayedCancelGhost());
            }
        }