Example #1
0
        public WallDoor.Actions ToggleDoorStatusAction(bool mp)
        {
            WallChunkArchitect componentInParent = base.GetComponentInParent <WallChunkArchitect>();

            if (mp && BoltNetwork.isRunning && base.entity.isAttached)
            {
                ToggleWallDoor toggleWallDoor = ToggleWallDoor.Create(GlobalTargets.OnlyServer);
                toggleWallDoor.Entity = base.entity;
                toggleWallDoor.Send();
            }
            else
            {
                if (componentInParent.Addition >= WallChunkArchitect.Additions.LockedDoor1)
                {
                    componentInParent.Addition = ((componentInParent.Addition != WallChunkArchitect.Additions.LockedDoor1) ? WallChunkArchitect.Additions.Door2 : WallChunkArchitect.Additions.Door1);
                }
                else
                {
                    componentInParent.Addition = ((componentInParent.Addition != WallChunkArchitect.Additions.Door1) ? WallChunkArchitect.Additions.LockedDoor2 : WallChunkArchitect.Additions.LockedDoor1);
                }
                if (BoltNetwork.isServer)
                {
                    base.state.Addition = (int)componentInParent.Addition;
                    if (base.entity.isOwner)
                    {
                        ((CoopWallChunkToken)base.entity.attachToken).Additions = componentInParent.Addition;
                    }
                }
                this.PlaySfx((componentInParent.Addition < WallChunkArchitect.Additions.LockedDoor1) ? WallDoor.Actions.Openning : WallDoor.Actions.Closing);
            }
            return((componentInParent.Addition < WallChunkArchitect.Additions.LockedDoor1) ? WallDoor.Actions.Openning : WallDoor.Actions.Closing);
        }
Example #2
0
        private void SpawnRepairTrigger()
        {
            if (this._repairTrigger || !this._canBeRepaired)
            {
                return;
            }
            if (BoltNetwork.isRunning && base.entity && base.entity.isAttached && base.entity.isOwner)
            {
                base.state.repairTrigger = true;
            }
            this._repairTrigger                  = UnityEngine.Object.Instantiate <BuildingRepair>(Prefabs.Instance.BuildingRepairTriggerPrefab);
            this._repairTrigger._target          = this;
            this._repairTrigger.transform.parent = base.transform;
            IStructureSupport structureSupport = (IStructureSupport)base.GetComponent(typeof(IStructureSupport));

            if (structureSupport != null)
            {
                if (structureSupport is WallChunkArchitect)
                {
                    WallChunkArchitect wallChunkArchitect = (WallChunkArchitect)structureSupport;
                    this._repairTrigger.transform.position = Vector3.Lerp(wallChunkArchitect.P1, wallChunkArchitect.P2, 0.5f) + base.transform.right + base.transform.TransformDirection(this._repairTriggerOffset);
                    this._repairTrigger.transform.rotation = Quaternion.LookRotation(base.transform.right);
                }
                else
                {
                    this._repairTrigger.transform.position = MultipointUtils.CenterOf(structureSupport.GetMultiPointsPositions(true)) + base.transform.TransformDirection(this._repairTriggerOffset);
                }
            }
            else
            {
                this._repairTrigger.transform.position = base.transform.position + base.transform.TransformDirection(this._repairTriggerOffset);
            }
        }
    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");
        }
    }
Example #4
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");
    }
    public static void AttachBuildingBoltEntity(BoltEntity entity)
    {
        if (!BoltNetwork.isServer)
        {
            return;
        }
        if (!CoopSteamServerStarter.SaveIsLoading)
        {
            return;
        }
        if (!entity)
        {
            return;
        }
        if (entity.IsAttached())
        {
            return;
        }
        BoltEntitySettingsModifier boltEntitySettingsModifier = entity.ModifySettings();
        BridgeArchitect            component  = entity.GetComponent <BridgeArchitect>();
        ZiplineArchitect           component2 = entity.GetComponent <ZiplineArchitect>();
        GardenArchitect            component3 = entity.GetComponent <GardenArchitect>();
        CraneArchitect             component4 = entity.GetComponent <CraneArchitect>();

        if (boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IFireState)
        {
            BoltNetwork.Attach(entity);
        }
        else if (boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IRaftState)
        {
            BoltNetwork.Attach(entity);
            if (entity && entity.isAttached && entity.StateIs <IRaftState>())
            {
                entity.GetState <IRaftState>().IsReal = true;
            }
        }
        else if (boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IMultiHolderState)
        {
            BoltNetwork.Attach(entity);
            if (entity && entity.isAttached && entity.StateIs <IMultiHolderState>())
            {
                entity.GetState <IMultiHolderState>().IsReal = true;
                MultiHolder[] componentsInChildren = entity.GetComponentsInChildren <MultiHolder>(true);
                if (componentsInChildren.Length > 0)
                {
                    componentsInChildren[0]._contentActual     = componentsInChildren[0]._contentAmount;
                    componentsInChildren[0]._contentTypeActual = componentsInChildren[0]._content;
                }
            }
        }
        else if (component)
        {
            BoltNetwork.Attach(entity, component.CustomToken);
        }
        else if (component2)
        {
            BoltNetwork.Attach(entity, component2.CustomToken);
        }
        else if (component3)
        {
            BoltNetwork.Attach(entity, component3.CustomToken);
        }
        else if (component4)
        {
            BoltNetwork.Attach(entity, component4.CustomToken);
        }
        else if (boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IFoundationState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IBuildingState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IRabbitCage || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.ITreeBuildingState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.ITrapLargeState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IBuildingDestructibleState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IWallChunkBuildingState)
        {
            CoopBuildingEx     component5 = entity.GetComponent <CoopBuildingEx>();
            WallChunkArchitect component6 = entity.GetComponent <WallChunkArchitect>();
            if (component6)
            {
                BoltNetwork.Attach(entity, component6.CustomToken);
            }
            else if (component5)
            {
                CoopConstructionExToken coopConstructionExToken = new CoopConstructionExToken();
                coopConstructionExToken.Architects = new CoopConstructionExToken.ArchitectData[component5.Architects.Length];
                for (int i = 0; i < component5.Architects.Length; i++)
                {
                    coopConstructionExToken.Architects[i].PointsCount     = (component5.Architects[i] as ICoopStructure).MultiPointsCount;
                    coopConstructionExToken.Architects[i].PointsPositions = (component5.Architects[i] as ICoopStructure).MultiPointsPositions.ToArray();
                    coopConstructionExToken.Architects[i].CustomToken     = (component5.Architects[i] as ICoopStructure).CustomToken;
                    if (component5.Architects[i] is FoundationArchitect)
                    {
                        coopConstructionExToken.Architects[i].AboveGround = ((FoundationArchitect)component5.Architects[i])._aboveGround;
                    }
                    if (component5.Architects[i] is RoofArchitect && (component5.Architects[i] as RoofArchitect).CurrentSupport != null)
                    {
                        coopConstructionExToken.Architects[i].Support = ((component5.Architects[i] as RoofArchitect).CurrentSupport as MonoBehaviour).GetComponent <BoltEntity>();
                    }
                    if (component5.Architects[i] is FloorArchitect && (component5.Architects[i] as FloorArchitect).CurrentSupport != null)
                    {
                        coopConstructionExToken.Architects[i].Support = ((component5.Architects[i] as FloorArchitect).CurrentSupport as MonoBehaviour).GetComponent <BoltEntity>();
                    }
                    CoopSteamServerStarter.AttachBuildingBoltEntity(coopConstructionExToken.Architects[i].Support);
                }
                BoltNetwork.Attach(entity, coopConstructionExToken);
            }
            else
            {
                BoltNetwork.Attach(entity);
            }
        }
        else if (boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IConstructionState || boltEntitySettingsModifier.serializerId == StateSerializerTypeIds.IWallChunkConstructionState)
        {
            CoopConstructionEx component7 = entity.GetComponent <CoopConstructionEx>();
            WallChunkArchitect component8 = entity.GetComponent <WallChunkArchitect>();
            if (component8)
            {
                BoltNetwork.Attach(entity, component8.CustomToken);
            }
            else if (component7)
            {
                CoopConstructionExToken coopConstructionExToken2 = new CoopConstructionExToken();
                coopConstructionExToken2.Architects = new CoopConstructionExToken.ArchitectData[component7.Architects.Length];
                for (int j = 0; j < component7.Architects.Length; j++)
                {
                    coopConstructionExToken2.Architects[j].PointsCount     = (component7.Architects[j] as ICoopStructure).MultiPointsCount;
                    coopConstructionExToken2.Architects[j].PointsPositions = (component7.Architects[j] as ICoopStructure).MultiPointsPositions.ToArray();
                    coopConstructionExToken2.Architects[j].CustomToken     = (component7.Architects[j] as ICoopStructure).CustomToken;
                    if (component7.Architects[j] is FoundationArchitect)
                    {
                        coopConstructionExToken2.Architects[j].AboveGround = ((FoundationArchitect)component7.Architects[j])._aboveGround;
                    }
                    if (component7.Architects[j] is RoofArchitect && (component7.Architects[j] as RoofArchitect).CurrentSupport != null)
                    {
                        coopConstructionExToken2.Architects[j].Support = ((component7.Architects[j] as RoofArchitect).CurrentSupport as MonoBehaviour).GetComponent <BoltEntity>();
                    }
                    if (component7.Architects[j] is FloorArchitect && (component7.Architects[j] as FloorArchitect).CurrentSupport != null)
                    {
                        coopConstructionExToken2.Architects[j].Support = ((component7.Architects[j] as FloorArchitect).CurrentSupport as MonoBehaviour).GetComponent <BoltEntity>();
                    }
                    CoopSteamServerStarter.AttachBuildingBoltEntity(coopConstructionExToken2.Architects[j].Support);
                }
                BoltNetwork.Attach(entity, coopConstructionExToken2);
            }
            else
            {
                BoltNetwork.Attach(entity);
            }
        }
    }