public static EntitySpawnPoint From(Int3 batchId, GameObject go, CellManager.CellHeader cellHeader)
        {
            // Why is this not a constructor?
            EntitySpawnPoint esp = new EntitySpawnPoint
            {
                Level   = cellHeader.level,
                ClassId = go.ClassId,
                BatchId = batchId,
                CellId  = cellHeader.cellId
            };

            EntitySlot entitySlot = go.GetComponent <EntitySlot>();

            if (!ReferenceEquals(entitySlot, null))
            {
                esp.BiomeType        = entitySlot.biomeType;
                esp.Density          = entitySlot.density;
                esp.CanSpawnCreature = entitySlot.IsCreatureSlot();
            }

            Vector3 localPosition = go.GetComponent <Transform>().Position;

            Int3.Bounds         bounds = BatchCells.GetBlockBounds(batchId, cellHeader.cellId, 0, Map.BATCH_DIMENSIONS);
            UnityEngine.Vector3 center = EntityCell.GetCenter(bounds);

            esp.Position = new UnityEngine.Vector3(center.x + localPosition.x - Map.BATCH_DIMENSION_CENTERING.x,
                                                   center.y + localPosition.y - Map.BATCH_DIMENSION_CENTERING.y,
                                                   center.z + localPosition.z - Map.BATCH_DIMENSION_CENTERING.z);
            return(esp);
        }
示例#2
0
        public static EntitySpawnPoint From(Int3 batchId, GameObject go, CellManager.CellHeader cellHeader)
        {
            // Why is this not a constructor?
            EntitySpawnPoint esp = new EntitySpawnPoint
            {
                AbsoluteEntityCell = new AbsoluteEntityCell(batchId, cellHeader.cellId, cellHeader.level),
                ClassId            = go.ClassId,
                Density            = 1
            };

            EntitySlot entitySlot = go.GetComponent <EntitySlot>();

            if (!ReferenceEquals(entitySlot, null))
            {
                esp.BiomeType        = entitySlot.biomeType;
                esp.Density          = entitySlot.density;
                esp.CanSpawnCreature = entitySlot.IsCreatureSlot();
                esp.AllowedTypes     = entitySlot.allowedTypes;
            }

            esp.Rotation = go.GetComponent <Transform>().Rotation;

            UnityEngine.Vector3 localPosition = go.GetComponent <Transform>().Position;
            esp.Position = esp.AbsoluteEntityCell.Center + localPosition;
            esp.Scale    = go.GetComponent <Transform>().Scale;

            return(esp);
        }