示例#1
0
 public static void AttachTrees()
 {
     if (BoltNetwork.isServer && CoopTreeGrid.AttachQueue != null)
     {
         int count = CoopTreeGrid.AttachQueue.Count;
         for (int i = 0; i < 100; i++)
         {
             if (CoopTreeGrid.AttachQueue.Count <= 0)
             {
                 break;
             }
             BoltEntity boltEntity = CoopTreeGrid.AttachQueue.Dequeue();
             if (!boltEntity.IsAttached())
             {
                 BoltNetwork.Attach(boltEntity.gameObject);
                 boltEntity.Freeze(true);
             }
             else
             {
                 i--;
             }
         }
         if (count > 0 && CoopTreeGrid.AttachQueue.Count == 0 && !CoopTreeGrid.AttachRoutineDone)
         {
             CoopTreeGrid.AttachRoutineDone = true;
             Scene.ActiveMB.StartCoroutine(CoopTreeGrid.AttacheRoutine());
         }
     }
 }
示例#2
0
    public void ReceiveVoiceData(byte[] packet, int o)
    {
        BoltEntity componentInParent = base.GetComponentInParent <BoltEntity>();

        if (componentInParent.IsAttached())
        {
            int    num   = Blit.ReadI32(packet, ref o);
            byte[] array = new byte[num];
            Blit.ReadBytes(packet, ref o, array, 0, num);
            this.ReceiveVoiceData_Unpacked(array, num);
        }
    }
示例#3
0
 public override void EntityDetached(BoltEntity arg)
 {
     if (arg.IsAttached() && arg.StateIs <IPlayerState>())
     {
         try
         {
             ChatBox.Instance.UnregisterPlayer(arg.networkId);
         }
         catch
         {
         }
     }
 }
示例#4
0
    public override void StreamDataReceived(BoltConnection connection, UdpStreamData data)
    {
        int        o          = 0;
        BoltEntity boltEntity = BoltNetwork.FindEntity(new NetworkId(Blit.ReadU64(data.Data, ref o)));

        if (boltEntity.IsAttached())
        {
            CoopVoice component = boltEntity.GetComponent <CoopVoice>();
            if (component)
            {
                component.ReceiveVoiceData(data.Data, o);
            }
        }
    }
示例#5
0
 public override void EntityDetached(BoltEntity arg)
 {
     if (arg.IsAttached() && arg.StateIs <IPlayerState>())
     {
         try
         {
             if (arg.source.UserData as BoltEntity == arg)
             {
                 arg.source.UserData = null;
             }
             TheForest.Utils.Scene.HudGui.Chatbox.UnregisterPlayer(arg.networkId);
         }
         catch
         {
         }
     }
 }
示例#6
0
 internal static void AttachTrees()
 {
     if (BoltNetwork.isServer && CoopTreeGrid.AttachQueue != null)
     {
         int count = CoopTreeGrid.AttachQueue.Count;
         for (int i = 0; i < 10; i++)
         {
             if (CoopTreeGrid.AttachQueue.Count <= 0)
             {
                 break;
             }
             BoltEntity boltEntity = CoopTreeGrid.AttachQueue.Dequeue();
             if (!boltEntity.IsAttached())
             {
                 BoltNetwork.Attach(boltEntity.gameObject);
                 boltEntity.Freeze(true);
             }
             else
             {
                 i--;
             }
         }
         if (count > 0 && CoopTreeGrid.AttachQueue.Count == 0)
         {
             BoltEntity[] array = UnityEngine.Object.FindObjectsOfType <BoltEntity>();
             for (int j = 0; j < array.Length; j++)
             {
                 BoltEntity entity = array[j];
                 if (!entity.IsAttached())
                 {
                     BoltNetwork.Attach(entity);
                 }
             }
         }
     }
 }
示例#7
0
 public static bool IsOwner(this BoltEntity entity)
 {
     return(entity.IsAttached() && entity.isOwner);
 }
    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);
            }
        }
    }
 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>();
     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 (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 component2 = entity.GetComponent<CoopBuildingEx>();
         WallChunkArchitect component3 = entity.GetComponent<WallChunkArchitect>();
         if (component3)
         {
             BoltNetwork.Attach(entity, component3.CustomToken);
         }
         else if (component2)
         {
             CoopConstructionExToken coopConstructionExToken = new CoopConstructionExToken();
             coopConstructionExToken.Architects = new CoopConstructionExToken.ArchitectData[component2.Architects.Length];
             for (int i = 0; i < component2.Architects.Length; i++)
             {
                 coopConstructionExToken.Architects[i].PointsCount = (component2.Architects[i] as ICoopStructure).MultiPointsCount;
                 coopConstructionExToken.Architects[i].PointsPositions = (component2.Architects[i] as ICoopStructure).MultiPointsPositions.ToArray();
                 coopConstructionExToken.Architects[i].CustomToken = (component2.Architects[i] as ICoopStructure).CustomToken;
                 if (component2.Architects[i] is FoundationArchitect)
                 {
                     coopConstructionExToken.Architects[i].AboveGround = ((FoundationArchitect)component2.Architects[i])._aboveGround;
                 }
                 if (component2.Architects[i] is RoofArchitect && (component2.Architects[i] as RoofArchitect).CurrentSupport != null)
                 {
                     coopConstructionExToken.Architects[i].Support = ((component2.Architects[i] as RoofArchitect).CurrentSupport as MonoBehaviour).GetComponent<BoltEntity>();
                 }
                 if (component2.Architects[i] is FloorArchitect && (component2.Architects[i] as FloorArchitect).CurrentSupport != null)
                 {
                     coopConstructionExToken.Architects[i].Support = ((component2.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 component4 = entity.GetComponent<CoopConstructionEx>();
         WallChunkArchitect component5 = entity.GetComponent<WallChunkArchitect>();
         if (component5)
         {
             BoltNetwork.Attach(entity, component5.CustomToken);
         }
         else if (component4)
         {
             CoopConstructionExToken coopConstructionExToken2 = new CoopConstructionExToken();
             coopConstructionExToken2.Architects = new CoopConstructionExToken.ArchitectData[component4.Architects.Length];
             for (int j = 0; j < component4.Architects.Length; j++)
             {
                 coopConstructionExToken2.Architects[j].PointsCount = (component4.Architects[j] as ICoopStructure).MultiPointsCount;
                 coopConstructionExToken2.Architects[j].PointsPositions = (component4.Architects[j] as ICoopStructure).MultiPointsPositions.ToArray();
                 coopConstructionExToken2.Architects[j].CustomToken = (component4.Architects[j] as ICoopStructure).CustomToken;
                 if (component4.Architects[j] is FoundationArchitect)
                 {
                     coopConstructionExToken2.Architects[j].AboveGround = ((FoundationArchitect)component4.Architects[j])._aboveGround;
                 }
                 if (component4.Architects[j] is RoofArchitect && (component4.Architects[j] as RoofArchitect).CurrentSupport != null)
                 {
                     coopConstructionExToken2.Architects[j].Support = ((component4.Architects[j] as RoofArchitect).CurrentSupport as MonoBehaviour).GetComponent<BoltEntity>();
                 }
                 if (component4.Architects[j] is FloorArchitect && (component4.Architects[j] as FloorArchitect).CurrentSupport != null)
                 {
                     coopConstructionExToken2.Architects[j].Support = ((component4.Architects[j] as FloorArchitect).CurrentSupport as MonoBehaviour).GetComponent<BoltEntity>();
                 }
                 CoopSteamServerStarter.AttachBuildingBoltEntity(coopConstructionExToken2.Architects[j].Support);
             }
             BoltNetwork.Attach(entity, coopConstructionExToken2);
         }
         else
         {
             BoltNetwork.Attach(entity);
         }
     }
 }