Esempio n. 1
0
 private void OnEntityKill(DoorManipulator doorManipulator)
 {
     if (doorManipulator == null || doorManipulators == null)
     {
         return;
     }
     doorManipulators.RemoveWhere(x => x == doorManipulator);
 }
Esempio n. 2
0
 private void OnEntitySpawned(DoorManipulator doorManipulator)
 {
     if (doorManipulator == null || doorManipulator.OwnerID == 0)
     {
         return;
     }
     doorManipulators.Add(doorManipulator);
 }
Esempio n. 3
0
        public void PuzzlePrefabRespawn(ConsoleSystem.Arg arg)
        {
            foreach (BaseNetworkable baseNetworkable in BaseNetworkable.serverEntities.Where <BaseNetworkable>((Func <BaseNetworkable, bool>)(x => x is IOEntity && ((BaseEntity)x).OwnerID == 0)).ToList <BaseNetworkable>())
            {
                baseNetworkable.Kill(BaseNetworkable.DestroyMode.None);
            }
            foreach (MonumentInfo monument in TerrainMeta.Path.Monuments)
            {
                GameObject prefab = GameManager.server.FindPrefab(monument.gameObject.name);
                if (!((UnityEngine.Object)prefab == (UnityEngine.Object)null))
                {
                    Dictionary <IOEntity, IOEntity> dictionary = new Dictionary <IOEntity, IOEntity>();
                    foreach (IOEntity componentsInChild in prefab.GetComponentsInChildren <IOEntity>(true))
                    {
                        Quaternion rot       = monument.transform.rotation * componentsInChild.transform.rotation;
                        Vector3    pos       = monument.transform.TransformPoint(componentsInChild.transform.position);
                        BaseEntity newEntity = GameManager.server.CreateEntity(componentsInChild.PrefabName, pos, rot, true);
                        IOEntity   ioEntity  = newEntity as IOEntity;
                        if ((UnityEngine.Object)ioEntity != (UnityEngine.Object)null)
                        {
                            dictionary.Add(componentsInChild, ioEntity);
                            DoorManipulator doorManipulator = newEntity as DoorManipulator;
                            if ((UnityEngine.Object)doorManipulator != (UnityEngine.Object)null)
                            {
                                List <Door> list = Facepunch.Pool.GetList <Door>();
                                global::Vis.Entities <Door>(newEntity.transform.position, 10f, list, -1, QueryTriggerInteraction.Collide);
                                Door door = list.OrderBy <Door, float>((Func <Door, float>)(x => x.Distance(newEntity.transform.position))).FirstOrDefault <Door>();
                                if ((UnityEngine.Object)door != (UnityEngine.Object)null)
                                {
                                    doorManipulator.targetDoor = door;
                                }
                                Facepunch.Pool.FreeList <Door>(ref list);
                            }
                            CardReader cardReader1 = newEntity as CardReader;
                            if ((UnityEngine.Object)cardReader1 != (UnityEngine.Object)null)
                            {
                                CardReader cardReader2 = componentsInChild as CardReader;
                                if ((UnityEngine.Object)cardReader2 != (UnityEngine.Object)null)
                                {
                                    cardReader1.accessLevel    = cardReader2.accessLevel;
                                    cardReader1.accessDuration = cardReader2.accessDuration;
                                }
                            }
                            TimerSwitch timerSwitch1 = newEntity as TimerSwitch;
                            if ((UnityEngine.Object)timerSwitch1 != (UnityEngine.Object)null)
                            {
                                TimerSwitch timerSwitch2 = componentsInChild as TimerSwitch;
                                if ((UnityEngine.Object)timerSwitch2 != (UnityEngine.Object)null)
                                {
                                    timerSwitch1.timerLength = timerSwitch2.timerLength;
                                }
                            }
                        }
                    }

                    foreach (KeyValuePair <IOEntity, IOEntity> keyValuePair in dictionary)
                    {
                        IOEntity key      = keyValuePair.Key;
                        IOEntity ioEntity = keyValuePair.Value;
                        for (int index = 0; index < key.outputs.Length; ++index)
                        {
                            if (!((UnityEngine.Object)key.outputs[index].connectedTo.Get() == (UnityEngine.Object)null))
                            {
                                ioEntity.outputs[index].connectedTo.ioEnt = dictionary[key.outputs[index].connectedTo.ioEnt];
                                ioEntity.outputs[index].connectedToSlot   = key.outputs[index].connectedToSlot;
                            }
                        }
                    }
                    foreach (BaseNetworkable baseNetworkable in dictionary.Values)
                    {
                        baseNetworkable.Spawn();
                    }
                }
            }
        }
Esempio n. 4
0
 public static void puzzleprefabrespawn(ConsoleSystem.Arg arg)
 {
     foreach (BaseNetworkable baseNetworkable in BaseNetworkable.serverEntities.Where <BaseNetworkable>((Func <BaseNetworkable, bool>)(x =>
     {
         if (x is IOEntity)
         {
             return((PrefabAttribute)PrefabAttribute.server.Find <Construction>(x.prefabID) == (PrefabAttribute)null);
         }
         return(false);
     })).ToList <BaseNetworkable>())
     {
         baseNetworkable.Kill(BaseNetworkable.DestroyMode.None);
     }
     foreach (MonumentInfo monument in TerrainMeta.Path.Monuments)
     {
         GameObject prefab = GameManager.server.FindPrefab(((Object)((Component)monument).get_gameObject()).get_name());
         if (!Object.op_Equality((Object)prefab, (Object)null))
         {
             Dictionary <IOEntity, IOEntity> dictionary = new Dictionary <IOEntity, IOEntity>();
             foreach (IOEntity componentsInChild in (IOEntity[])prefab.GetComponentsInChildren <IOEntity>(true))
             {
                 Quaternion rot       = Quaternion.op_Multiply(((Component)monument).get_transform().get_rotation(), ((Component)componentsInChild).get_transform().get_rotation());
                 Vector3    pos       = ((Component)monument).get_transform().TransformPoint(((Component)componentsInChild).get_transform().get_position());
                 BaseEntity newEntity = GameManager.server.CreateEntity(componentsInChild.PrefabName, pos, rot, true);
                 IOEntity   ioEntity  = newEntity as IOEntity;
                 if (Object.op_Inequality((Object)ioEntity, (Object)null))
                 {
                     dictionary.Add(componentsInChild, ioEntity);
                     DoorManipulator doorManipulator = newEntity as DoorManipulator;
                     if (Object.op_Inequality((Object)doorManipulator, (Object)null))
                     {
                         List <Door> list = (List <Door>)Pool.GetList <Door>();
                         global::Vis.Entities <Door>(((Component)newEntity).get_transform().get_position(), 10f, list, -1, (QueryTriggerInteraction)2);
                         Door door = list.OrderBy <Door, float>((Func <Door, float>)(x => x.Distance(((Component)newEntity).get_transform().get_position()))).FirstOrDefault <Door>();
                         if (Object.op_Inequality((Object)door, (Object)null))
                         {
                             doorManipulator.targetDoor = door;
                         }
                         // ISSUE: cast to a reference type
                         Pool.FreeList <Door>((List <M0>&) ref list);
                     }
                     CardReader cardReader1 = newEntity as CardReader;
                     if (Object.op_Inequality((Object)cardReader1, (Object)null))
                     {
                         CardReader cardReader2 = componentsInChild as CardReader;
                         if (Object.op_Inequality((Object)cardReader2, (Object)null))
                         {
                             cardReader1.accessLevel    = cardReader2.accessLevel;
                             cardReader1.accessDuration = cardReader2.accessDuration;
                         }
                     }
                     TimerSwitch timerSwitch1 = newEntity as TimerSwitch;
                     if (Object.op_Inequality((Object)timerSwitch1, (Object)null))
                     {
                         TimerSwitch timerSwitch2 = componentsInChild as TimerSwitch;
                         if (Object.op_Inequality((Object)timerSwitch2, (Object)null))
                         {
                             timerSwitch1.timerLength = timerSwitch2.timerLength;
                         }
                     }
                 }
             }
             foreach (KeyValuePair <IOEntity, IOEntity> keyValuePair in dictionary)
             {
                 IOEntity key      = keyValuePair.Key;
                 IOEntity ioEntity = keyValuePair.Value;
                 for (int index = 0; index < key.outputs.Length; ++index)
                 {
                     if (!Object.op_Equality((Object)key.outputs[index].connectedTo.ioEnt, (Object)null))
                     {
                         ioEntity.outputs[index].connectedTo.ioEnt = dictionary[key.outputs[index].connectedTo.ioEnt];
                         ioEntity.outputs[index].connectedToSlot   = key.outputs[index].connectedToSlot;
                     }
                 }
             }
             foreach (BaseNetworkable baseNetworkable in dictionary.Values)
             {
                 baseNetworkable.Spawn();
             }
         }
     }
 }
 public static void puzzleprefabrespawn(ConsoleSystem.Arg arg)
 {
     foreach (BaseNetworkable list in BaseNetworkable.serverEntities.Where <BaseNetworkable>((BaseNetworkable x) => {
         if (!(x is IOEntity))
         {
             return(false);
         }
         return(PrefabAttribute.server.Find <Construction>(x.prefabID) == null);
     }).ToList <BaseNetworkable>())
     {
         list.Kill(BaseNetworkable.DestroyMode.None);
     }
     foreach (MonumentInfo monument in TerrainMeta.Path.Monuments)
     {
         GameObject gameObject = GameManager.server.FindPrefab(monument.gameObject.name);
         if (gameObject == null)
         {
             continue;
         }
         Dictionary <IOEntity, IOEntity> oEntities = new Dictionary <IOEntity, IOEntity>();
         IOEntity[] componentsInChildren           = gameObject.GetComponentsInChildren <IOEntity>(true);
         for (int i = 0; i < (int)componentsInChildren.Length; i++)
         {
             IOEntity   oEntity    = componentsInChildren[i];
             Quaternion quaternion = monument.transform.rotation * oEntity.transform.rotation;
             Vector3    vector3    = monument.transform.TransformPoint(oEntity.transform.position);
             BaseEntity baseEntity = GameManager.server.CreateEntity(oEntity.PrefabName, vector3, quaternion, true);
             IOEntity   oEntity1   = baseEntity as IOEntity;
             if (oEntity1 != null)
             {
                 oEntities.Add(oEntity, oEntity1);
                 DoorManipulator doorManipulator = baseEntity as DoorManipulator;
                 if (doorManipulator != null)
                 {
                     List <Door> doors = Facepunch.Pool.GetList <Door>();
                     Vis.Entities <Door>(baseEntity.transform.position, 10f, doors, -1, QueryTriggerInteraction.Collide);
                     Door door = (
                         from x in doors
                         orderby x.Distance(baseEntity.transform.position)
                         select x).FirstOrDefault <Door>();
                     if (door != null)
                     {
                         doorManipulator.targetDoor = door;
                     }
                     Facepunch.Pool.FreeList <Door>(ref doors);
                 }
                 CardReader cardReader = baseEntity as CardReader;
                 if (cardReader != null)
                 {
                     CardReader cardReader1 = oEntity as CardReader;
                     if (cardReader1 != null)
                     {
                         cardReader.accessLevel    = cardReader1.accessLevel;
                         cardReader.accessDuration = cardReader1.accessDuration;
                     }
                 }
                 TimerSwitch timerSwitch = baseEntity as TimerSwitch;
                 if (timerSwitch != null)
                 {
                     TimerSwitch timerSwitch1 = oEntity as TimerSwitch;
                     if (timerSwitch1 != null)
                     {
                         timerSwitch.timerLength = timerSwitch1.timerLength;
                     }
                 }
             }
         }
         foreach (KeyValuePair <IOEntity, IOEntity> keyValuePair in oEntities)
         {
             IOEntity key   = keyValuePair.Key;
             IOEntity value = keyValuePair.Value;
             for (int j = 0; j < (int)key.outputs.Length; j++)
             {
                 if (key.outputs[j].connectedTo.ioEnt != null)
                 {
                     value.outputs[j].connectedTo.ioEnt = oEntities[key.outputs[j].connectedTo.ioEnt];
                     value.outputs[j].connectedToSlot   = key.outputs[j].connectedToSlot;
                 }
             }
         }
         foreach (IOEntity value1 in oEntities.Values)
         {
             value1.Spawn();
         }
     }
 }
Esempio n. 6
0
 public static void puzzleprefabrespawn(Arg arg)
 {
     foreach (BaseNetworkable item in BaseNetworkable.serverEntities.Where((BaseNetworkable x) => x is IOEntity && PrefabAttribute.server.Find <Construction>(x.prefabID) == null).ToList())
     {
         item.Kill();
     }
     foreach (MonumentInfo monument in TerrainMeta.Path.Monuments)
     {
         GameObject gameObject = GameManager.server.FindPrefab(monument.gameObject.name);
         if (gameObject == null)
         {
             continue;
         }
         Dictionary <IOEntity, IOEntity> dictionary = new Dictionary <IOEntity, IOEntity>();
         IOEntity[] componentsInChildren            = gameObject.GetComponentsInChildren <IOEntity>(true);
         foreach (IOEntity iOEntity in componentsInChildren)
         {
             Quaternion rot       = monument.transform.rotation * iOEntity.transform.rotation;
             Vector3    pos       = monument.transform.TransformPoint(iOEntity.transform.position);
             BaseEntity newEntity = GameManager.server.CreateEntity(iOEntity.PrefabName, pos, rot);
             IOEntity   iOEntity2 = newEntity as IOEntity;
             if (!(iOEntity2 != null))
             {
                 continue;
             }
             dictionary.Add(iOEntity, iOEntity2);
             DoorManipulator doorManipulator = newEntity as DoorManipulator;
             if (doorManipulator != null)
             {
                 List <Door> obj = Facepunch.Pool.GetList <Door>();
                 global::Vis.Entities(newEntity.transform.position, 10f, obj);
                 Door door = obj.OrderBy((Door x) => x.Distance(newEntity.transform.position)).FirstOrDefault();
                 if (door != null)
                 {
                     doorManipulator.targetDoor = door;
                 }
                 Facepunch.Pool.FreeList(ref obj);
             }
             CardReader cardReader = newEntity as CardReader;
             if (cardReader != null)
             {
                 CardReader cardReader2 = iOEntity as CardReader;
                 if (cardReader2 != null)
                 {
                     cardReader.accessLevel    = cardReader2.accessLevel;
                     cardReader.accessDuration = cardReader2.accessDuration;
                 }
             }
             TimerSwitch timerSwitch = newEntity as TimerSwitch;
             if (timerSwitch != null)
             {
                 TimerSwitch timerSwitch2 = iOEntity as TimerSwitch;
                 if (timerSwitch2 != null)
                 {
                     timerSwitch.timerLength = timerSwitch2.timerLength;
                 }
             }
         }
         foreach (KeyValuePair <IOEntity, IOEntity> item2 in dictionary)
         {
             IOEntity key   = item2.Key;
             IOEntity value = item2.Value;
             for (int j = 0; j < key.outputs.Length; j++)
             {
                 if (!(key.outputs[j].connectedTo.ioEnt == null))
                 {
                     value.outputs[j].connectedTo.ioEnt = dictionary[key.outputs[j].connectedTo.ioEnt];
                     value.outputs[j].connectedToSlot   = key.outputs[j].connectedToSlot;
                 }
             }
         }
         foreach (IOEntity value2 in dictionary.Values)
         {
             value2.Spawn();
         }
     }
 }