Example #1
0
        public Optional <GameObject> Spawn(Entity entity, Optional <GameObject> parent)
        {
            TechType   techType = entity.TechType.Enum();
            GameObject prefab;

            if (!PrefabDatabase.TryGetPrefab(entity.ClassId, out prefab))
            {
                prefab = CraftData.GetPrefabForTechType(techType, false);
                if (prefab == null)
                {
                    return(Optional <GameObject> .Of(Utils.CreateGenericLoot(techType)));
                }
            }

            GameObject gameObject = Utils.SpawnFromPrefab(prefab, null);

            gameObject.transform.position   = entity.Position;
            gameObject.transform.localScale = entity.Scale;

            if (parent.IsPresent())
            {
                gameObject.transform.SetParent(parent.Get().transform, true);
            }

            gameObject.transform.localRotation = entity.Rotation;
            GuidHelper.SetNewGuid(gameObject, entity.Guid);
            gameObject.SetActive(true);

            LargeWorldEntity.Register(gameObject);
            CrafterLogic.NotifyCraftEnd(gameObject, techType);

            return(Optional <GameObject> .Of(gameObject));
        }
        public Optional <GameObject> Spawn(Entity entity, Optional <GameObject> parent)
        {
            GameObject prefabForTechType = CraftData.GetPrefabForTechType(entity.TechType, false);

            if (prefabForTechType == null && !PrefabDatabase.TryGetPrefab(entity.ClassId, out prefabForTechType))
            {
                return(Optional <GameObject> .Of(Utils.CreateGenericLoot(entity.TechType)));
            }

            GameObject gameObject = Utils.SpawnFromPrefab(prefabForTechType, null);

            gameObject.transform.position   = entity.Position;
            gameObject.transform.localScale = entity.Scale;

            if (parent.IsPresent())
            {
                gameObject.transform.SetParent(parent.Get().transform, true);
            }

            gameObject.transform.localRotation = entity.Rotation;
            GuidHelper.SetNewGuid(gameObject, entity.Guid);
            gameObject.SetActive(true);
            // Makes movable objects movable... we can probably do this before the server sends the spawner packet?
            if (gameObject.GetComponent <Rigidbody>() == null)
            {
                gameObject.AddComponent <Rigidbody>();
            }

            LargeWorldEntity.Register(gameObject);
            CrafterLogic.NotifyCraftEnd(gameObject, entity.TechType);

            return(Optional <GameObject> .Of(gameObject));
        }
Example #3
0
        public Optional <GameObject> Spawn(Entity entity, Optional <GameObject> parent)
        {
            GameObject prefabForTechType = CraftData.GetPrefabForTechType(entity.TechType, false);

            if (prefabForTechType == null && !PrefabDatabase.TryGetPrefab(entity.ClassId, out prefabForTechType))
            {
                return(Optional <GameObject> .Of(Utils.CreateGenericLoot(entity.TechType)));
            }

            GameObject gameObject = Utils.SpawnFromPrefab(prefabForTechType, null);

            gameObject.transform.position      = entity.Position;
            gameObject.transform.localRotation = entity.Rotation;
            GuidHelper.SetNewGuid(gameObject, entity.Guid);
            gameObject.SetActive(true);
            LargeWorldEntity.Register(gameObject);
            CrafterLogic.NotifyCraftEnd(gameObject, entity.TechType);

            return(Optional <GameObject> .Of(gameObject));
        }