protected ModPrefab_Fragment(
     string techTypeName,
     string friendlyName,
     TechType template,
     EntitySlot.Type slotType,
     bool prefabZUp,
     LargeWorldEntity.CellLevel cellLevel,
     Vector3 localScale,
     float scanTime        = 2,
     int totalFragments    = 2,
     bool destroyAfterScan = true
     )
     : base(techTypeName, $"{techTypeName}_Prefab")
 {
     TechTypeName     = techTypeName;
     FriendlyName     = friendlyName;
     FragmentTemplate = template;
     SlotType         = slotType;
     PrefabZUp        = prefabZUp;
     CellLevel        = cellLevel;
     LocalScale       = localScale;
     ScanTime         = scanTime;
     TotalFragments   = totalFragments;
     DestroyAfterScan = destroyAfterScan;
 }
Пример #2
0
        protected SeaTruckArmFragment(
            string techTypeName,
            string friendlyName,
            ArmFragmentTemplate fragmentTemplate,
            LargeWorldEntity.CellLevel cellLevel = LargeWorldEntity.CellLevel.Medium,
            float scanTime     = 3,
            int totalFragments = 3
            )
            : base(

                techTypeName,
                friendlyName,
                template: TechType.None,
                prefabFilePath: ArmFragmentTypes[fragmentTemplate],
                slotType: EntitySlot.Type.Small,
                prefabZUp: false,
                cellLevel: cellLevel,
                localScale: new Vector3(0.8f, 0.8f, 0.8f),
                scanTime: scanTime,
                totalFragments: totalFragments,
                destroyAfterScan: true
                )
        {
            ArmFragmentTemplate = fragmentTemplate;
        }
Пример #3
0
        public static void SetDefaultLargeWorldEntity(GameObject gameObj, LargeWorldEntity.CellLevel cellLevel = LargeWorldEntity.CellLevel.Near, int updaterIndex = 0)
        {
            if (gameObj == null)
            {
                return;
            }
            LargeWorldEntity lwe = gameObj.GetComponent <LargeWorldEntity>();

            if (lwe == null)
            {
                lwe = gameObj.AddComponent <LargeWorldEntity>();
            }
            lwe.cellLevel    = cellLevel;
            lwe.updaterIndex = updaterIndex;
            lwe.hideFlags    = HideFlags.None;
            lwe.useGUILayout = true;
            lwe.enabled      = true;
        }
Пример #4
0
 public static void UpdateExistingLargeWorldEntities(GameObject gameObj, LargeWorldEntity.CellLevel cellLevel = LargeWorldEntity.CellLevel.Near, int updaterIndex = -1)
 {
     if (gameObj == null)
     {
         return;
     }
     LargeWorldEntity[] entities = gameObj.GetComponentsInChildren <LargeWorldEntity>();
     if (entities != null)
     {
         foreach (LargeWorldEntity lwe in entities)
         {
             lwe.cellLevel = cellLevel;
             if (updaterIndex >= 0)
             {
                 lwe.updaterIndex = updaterIndex;
             }
         }
     }
 }
Пример #5
0
        private IEnumerable <Entity> CreateEntityWithChildren(EntitySpawnPoint entitySpawnPoint, TechType techType, LargeWorldEntity.CellLevel cellLevel, string classId)
        {
            Entity spawnedEntity = new Entity(entitySpawnPoint.Position,
                                              entitySpawnPoint.Rotation,
                                              techType,
                                              (int)cellLevel,
                                              classId);

            yield return(spawnedEntity);

            IEntityBootstrapper bootstrapper;

            if (customBootstrappersByTechType.TryGetValue(spawnedEntity.TechType, out bootstrapper))
            {
                bootstrapper.Prepare(spawnedEntity);

                foreach (Entity childEntity in spawnedEntity.ChildEntities)
                {
                    yield return(childEntity);
                }
            }
        }
 /// <summary>
 /// Adds in a custom <see cref="WorldEntityInfo"/> to the <see cref="WorldEntityDatabase"/> of the game.
 /// It contains information about the entity, like its <see cref="LargeWorldEntity.CellLevel"/>, its <see cref="EntitySlotData.EntitySlotType"/>, etc.
 /// </summary>
 /// <param name="classId">The classId of the entity.</param>
 /// <param name="techType">The <see cref="TechType"/> of the entity.</param>
 /// <param name="prefabZUp">Whether the prefab's Z-axis should be facing up, when spawned.</param>
 /// <param name="cellLevel">The <see cref="LargeWorldEntity.CellLevel"/> of the entity.</param>
 /// <param name="slotType">The <see cref="EntitySlot.Type"/> of the entity. Dictates which "slots" are suitable for this entity to spawn in. For e.g., most in-crate fragments have a <see cref="EntitySlot.Type.Small"/> slot type.</param>
 /// <param name="localScale">The scale that the entity's local scale is set to when spawned.</param>
 public static void AddCustomInfo(string classId, TechType techType, Vector3 localScale, bool prefabZUp = false, LargeWorldEntity.CellLevel cellLevel = LargeWorldEntity.CellLevel.Global, EntitySlot.Type slotType = EntitySlot.Type.Small)
 {
     Main.AddCustomInfo(classId, new WorldEntityInfo()
     {
         classId    = classId,
         techType   = techType,
         cellLevel  = cellLevel,
         slotType   = slotType,
         localScale = localScale,
         prefabZUp  = prefabZUp
     });
 }
Пример #7
0
        private IEnumerable <Entity> CreateEntityWithChildren(EntitySpawnPoint entitySpawnPoint, UnityEngine.Vector3 scale, TechType techType, LargeWorldEntity.CellLevel cellLevel, string classId, DeterministicBatchGenerator deterministicBatchGenerator)
        {
            Entity spawnedEntity = new Entity(entitySpawnPoint.Position,
                                              entitySpawnPoint.Rotation,
                                              scale,
                                              techType,
                                              (int)cellLevel,
                                              classId,
                                              true,
                                              deterministicBatchGenerator.NextGuid());

            yield return(spawnedEntity);

            IEntityBootstrapper bootstrapper;

            if (customBootstrappersByTechType.TryGetValue(spawnedEntity.TechType, out bootstrapper))
            {
                bootstrapper.Prepare(spawnedEntity, deterministicBatchGenerator);

                foreach (Entity childEntity in spawnedEntity.ChildEntities)
                {
                    yield return(childEntity);
                }
            }
        }