Ejemplo n.º 1
0
        protected IEnumerator SendPlayerToActionNode(int chunkID, string actionNodeName, float delay)
        {
            if (!GUILoading.IsLoading)
            {
                yield return(GUILoading.LoadStart(GUILoading.Mode.FullScreenBlack));
            }
            Player.Local.Despawn();
            //start off by setting the primary chunk
            GameWorld.Get.SetPrimaryChunk(chunkID);
            //action nodes won't exist unless it's primary
            while (GameWorld.Get.PrimaryChunk.CurrentMode != ChunkMode.Primary)              //wait for the chunk to load before we send it there
            //Debug.Log("Waiting for primary chunk to load");
            {
                yield return(null);
            }
            ActionNodeState nodeState = null;

            if (GameWorld.Get.PrimaryChunk.GetNode(actionNodeName, false, out nodeState))
            {
                //send player to location
                string     locationPath  = WIGroup.AllButLastInPath(nodeState.ParentGroupPath);
                string     locationName  = WIGroup.LastInPath(nodeState.ParentGroupPath);
                STransform spawnPosition = nodeState.Transform;
                if (nodeState.IsLoaded)
                {
                    spawnPosition = new STransform(nodeState.actionNode.transform, false);
                }
                yield return(StartCoroutine(SendPlayerToLocation(chunkID, locationPath, locationName, spawnPosition, GameWorld.Get.PrimaryChunk.ChunkOffset, delay)));
            }
            if (GUILoading.IsLoading)
            {
                yield return(GUILoading.LoadStart(GUILoading.Mode.FullScreenBlack));
            }
            yield break;
        }
Ejemplo n.º 2
0
 public void Clear( )
 {
     LightOffset   = null;
     Transform     = null;
     ChunkPosition = null;
     RemoveItemSkills.Clear();
 }
Ejemplo n.º 3
0
        public GOState(GameObject targetGO)
        {
            _targetGO = targetGO;

            // We always have a transform
            _savedTransform = new STransform(_targetGO.transform);
        }
Ejemplo n.º 4
0
    public static Transform LoadTransform(string name)
    {
        STransform structure = DefaultLoad <STransform>(GetPath(name));
        GameObject o         = new GameObject();
        Transform  t         = o.transform;

        t.localPosition = new Vector3(structure.pos[0], structure.pos[1], structure.pos[2]);
        t.localRotation = new Quaternion(structure.pos[3], structure.pos[4], structure.pos[5], structure.pos[6]);
        t.localScale    = new Vector3(structure.pos[7], structure.pos[8], structure.pos[9]);
        return(t);
    }
Ejemplo n.º 5
0
 public bool NextManualSpawnPoint(out STransform manualPoint)
 {
     manualPoint = null;
     if (ManualSpawnPoints.Count > 0)
     {
         bool looped = false;
         LastManualSpawnPointIndex = ManualSpawnPoints.NextIndex <STransform> (0, LastManualSpawnPointIndex, out looped);
         if (!looped)
         {
             manualPoint = ManualSpawnPoints [LastManualSpawnPointIndex];
             return(true);
         }
     }
     return(false);
 }
    public static STransform Serialize(this Transform _trans)
    {
        if (_trans == null)
        {
            return(null);
        }

        STransform returnVal = new STransform();

        returnVal.localPosition = _trans.localPosition.Serialize();
        returnVal.localRotation = _trans.localRotation.Serialize();
        returnVal.localScale    = _trans.localScale.Serialize();

        return(returnVal);
    }
    public static Transform Deserialize(this STransform _trans, ref GameObject _providedObject)
    {
        if (_trans == null)
        {
            return(null);
        }

        Transform returnVal = _providedObject.GetComponent <Transform>();

        returnVal.localPosition = _trans.localPosition.Deserialize();
        returnVal.localRotation = _trans.localRotation.Deserialize();
        returnVal.localScale    = _trans.localScale.Deserialize();

        return(returnVal);
    }
Ejemplo n.º 8
0
        public void OnPowerSourceRemoved()
        {
            if (mSpawnedDeactivatedOrb)
            {
                return;
            }
            //this will swap it out for an item that can be carried
            mSpawnedDeactivatedOrb = true;
            WorldItem  deactivatedOrb = null;
            STransform orbSpawnPoint  = new STransform(LuminiteGemPivot.position, LuminiteGemPivot.rotation.eulerAngles, Vector3.zero);

            if (WorldItems.CloneWorldItem(DeactivatedOrbGenericWorldItem, orbSpawnPoint, false, WIGroups.Get.World, out deactivatedOrb))
            {
                deactivatedOrb.Props.Local.Mode = WIMode.World;
                deactivatedOrb.Initialize();
                deactivatedOrb.SetMode(WIMode.World);
                worlditem.RemoveFromGame();
            }
        }
Ejemplo n.º 9
0
 public void OnDie()
 {
     PowerSource.HasPower = false;
     if (PowerSource.HasPowerSource)
     {
         //drop the crystal into the world
         WorldItem  droppedGem    = null;
         STransform gemSpawnPoint = new STransform(LuminiteGemPivot.position, LuminiteGemPivot.rotation.eulerAngles, Vector3.zero);
         if (WorldItems.CloneWorldItem(PowerSource.PowerSourceDopplegangerProps, gemSpawnPoint, false, WIGroups.Get.World, out droppedGem))
         {
             droppedGem.Props.Local.Mode = WIMode.World;
             droppedGem.Initialize();
             droppedGem.SetMode(WIMode.World);
             FXManager.Get.SpawnFX(droppedGem.tr, "DrawAttentionToItem");
         }
         FXManager.Get.SpawnExplosion(ExplosionType.Simple, worlditem.Position, 1f, 1f, 0.1f, 0.5f, OrbExplosionDamage);
     }
     OrbSpeak(OrbSpeakUnit.UnitExpiring, worlditem.tr);
 }
Ejemplo n.º 10
0
        protected IEnumerator FillWearablesOverTime(string categoryName)
        {
            //wait a frame
            yield return(null);

            //Debug.Log("Filling wearables from category " + categoryName);
            WICategory category = null;
            STransform tr       = new STransform();

            if (WorldItems.Get.Category(categoryName, out category))
            {
                //Debug.Log("Got category, filling now");
                for (int i = 0; i < category.GenericWorldItems.Count; i++)
                {
                    //get an instance of the item and try to wear it
                    //Debug.Log("Adding wearable " + category.GenericWorldItems[i].DisplayName);
                    for (int j = 0; j < category.GenericWorldItems[i].InstanceWeight; j++)
                    {
                        WorldItem newWorldItem = null;
                        if (WorldItems.CloneWorldItem(category.GenericWorldItems[i], tr, false, WIGroups.Get.Player, out newWorldItem))
                        {
                            newWorldItem.Initialize();
                            Wearable wearable = newWorldItem.Get <Wearable>();
                            if (!Wear(wearable))
                            {
                                //if we can't wear it for some reason, drop it in front of the player
                                player.ItemPlacement.ItemDropAtFeet(newWorldItem);
                            }
                            else
                            {
                                //Debug.Log("Player has been equipped with " + newWorldItem.DisplayName);
                            }
                        }
                    }
                }
            }
            else
            {
                //Debug.Log("Couldn't find category " + categoryName);
            }
            yield break;
        }
Ejemplo n.º 11
0
        void RecordTransform(ref List <STransform> record)
        {
            if (record == null)
            {
                record = new List <STransform>(transforms.Count);

                foreach (var t in transforms)
                {
                    record.Add(STransform.FromTransform(t));
                }
            }
            else
            {
                for (int i = 0; i < transforms.Count; i++)
                {
                    record[i] = STransform.FromTransform(transforms[i]);
                }
            }

            Debug.Assert(transforms.Count == record.Count);
        }
Ejemplo n.º 12
0
        public void AddStl(string stlFilepath)
        {
            if (!File.Exists(stlFilepath))
            {
                throw new ModelException($"STL file '{stlFilepath}' does not exist!");
            }

            var stlModel  = Wrapper.CreateModel();
            var stlReader = stlModel.QueryReader("stl");

            stlReader.ReadFromFile(stlFilepath);

            var stlMeshObjects = stlModel.GetMeshObjects();

            if (stlMeshObjects.Count() == 0)
            {
                throw new ModelException("Error occured while reading stl (lib3mf reader - 0).");
            }
            else if (stlMeshObjects.Count() > 1)
            {
                throw new ModelException("Error occured while reading stl (lib3mf reader > 1).");
            }

            stlMeshObjects.MoveNext();
            var stlMeshObject = stlMeshObjects.GetCurrentMeshObject();

            stlMeshObject.GetVertices(out sPosition[] vertices);
            stlMeshObject.GetTriangleIndices(out sTriangle[] triangles);

            var newMeshObject = _model.AddMeshObject();

            newMeshObject.SetName(Path.GetFileName(stlFilepath));
            newMeshObject.SetGeometry(vertices, triangles);

            var identityTransform = new STransform();

            Wrapper.GetIdentityTransform(identityTransform);
            _model.AddBuildItem(newMeshObject, identityTransform.__Instance);
        }
Ejemplo n.º 13
0
        public void ExtractPrintProject(string directory)
        {
            if (!Directory.Exists(directory))
            {
                throw new ModelException("Directory does not exist!");
            }

            var stlFolder = Path.Combine(directory, "stl");

            if (!Directory.Exists(stlFolder))
            {
                Directory.CreateDirectory(stlFolder);
            }

            var identityTransform = new STransform();

            Wrapper.GetIdentityTransform(identityTransform);

            foreach (var mesh in Meshes)
            {
                var stlModel = Wrapper.CreateModel();
                var stlMesh  = stlModel.AddMeshObject();
                stlMesh.SetName(mesh.Name);
                stlMesh.SetGeometry(mesh.NativeVertices, mesh.NativeTriangles);
                stlModel.AddBuildItem(stlMesh, identityTransform.__Instance);

                var stlWriter = stlModel.QueryWriter("stl");
                stlWriter.WriteToFile(Path.Combine(stlFolder, stlMesh.GetName()));
            }
            ZipFile.CreateFromDirectory(stlFolder, Path.Combine(directory, "stls.zip"));

            if (!string.IsNullOrEmpty(Readme))
            {
                File.WriteAllText(Path.Combine(directory, "README.md"), Readme);
            }
            ProjectFile?.Save(Path.Combine(directory, "3D2P.json"), true);
        }
Ejemplo n.º 14
0
    public static void LoadObj(GameObject inst, string objStr)
    {
        ISavable      toLoad   = inst.GetComponent <ISavable>();
        List <string> Objcomps = JsonUtility.FromJson <ListContainer <string> >(objStr).lis;

        Objcomps.RemoveAt(0);

        STransform temp = JsonUtility.FromJson <STransform>((string)Objcomps[0]);

        inst.transform.position   = temp.position;
        inst.transform.rotation   = temp.rotation;
        inst.transform.localScale = temp.scale;
        Objcomps.RemoveAt(0);



        FieldInfo[] prop = toLoad.GetType().GetFields();
        Array.Sort(prop, delegate(FieldInfo x, FieldInfo y) { return(x.Name.CompareTo(y.Name)); });


        foreach (FieldInfo p in prop)
        {
            Debug.Log(p);
            if (null != p && !p.IsNotSerialized)
            {
                Type pType = p.FieldType;

                object pVal = Activator.CreateInstance(pType);
                pVal = Convert.ChangeType(pVal, pType);
                Debug.Log(Objcomps[0]);
                JsonUtility.FromJsonOverwrite(Objcomps[0], pVal);

                p.SetValue(toLoad, pVal);
                Objcomps.RemoveAt(0);
            }
        }
    }
Ejemplo n.º 15
0
 public static Signboard AddLandmark(Signboard newSign, WorldItem owner, WIGroup locationGroup, STransform offset, string textureName)
 {
     newSign = GetOrCreateSignboard(newSign, owner, locationGroup, offset, textureName, "Landmark");
     Get.LandmarkSignboards.SafeAdd(newSign);
     return(newSign);
 }
 public static Transform Deserialize(this STransform _trans)
 {
     return((Transform)_trans);
 }
Ejemplo n.º 17
0
 public void CopyFrom(STransform transform)
 {
     Position = transform.Position;
     Rotation = transform.Rotation;
     Scale    = transform.Scale;
 }
Ejemplo n.º 18
0
 public static Signboard GetOrCreateSignboard(Signboard sign, WorldItem owner, WIGroup locationGroup, STransform offset, string textureName, string type)
 {
     if (sign == null)
     {
         WorldItem newSignWorldItem = null;
         WorldItems.CloneWorldItem("Decorations", "Signboard", offset, false, locationGroup, out newSignWorldItem);
         newSignWorldItem.Initialize();
         //offset.ApplyTo (newSignWorldItem.transform, false);
         sign             = newSignWorldItem.GetOrAdd <Signboard>();
         sign.Owner       = owner;
         sign.TextureName = textureName;
         sign.Style       = SignboardStyle.A;
         if (!string.IsNullOrEmpty(textureName))
         {
             if (textureName.StartsWith("B_"))
             {
                 sign.Style = SignboardStyle.B;
             }
             //Debug.Log ("Setting signoboard state to " + type + sign.Style.ToString ());
             newSignWorldItem.State = type + sign.Style.ToString();
         }
     }
     return(sign);
 }
Ejemplo n.º 19
0
 public bool IsApproximately(STransform transform)
 {
     return(Mathf.Approximately(Position.x, transform.Position.x) &&
            Mathf.Approximately(Position.y, transform.Position.y) &&
            Mathf.Approximately(Position.z, transform.Position.z));
 }
Ejemplo n.º 20
0
 public STransform(STransform tform)
 {
     Position = tform.Position;
     Rotation = tform.Rotation;
     Scale    = tform.Scale;
 }
Ejemplo n.º 21
0
        public void OnDie()
        {
            Debug.Log("OnDie called in drop items on die");
            if (gSpawnPointTransform == null)
            {
                gSpawnPointTransform = new STransform();
            }

            string categoryName = WICategoryName;

            if (!string.IsNullOrEmpty(WICategoryNameBurned))
            {
                if (worlditem.Get <Damageable> ().State.LastDamageSource == "Fire")
                {
                    categoryName = WICategoryNameBurned;
                }
            }

            if (DropEveryItemInCategory)
            {
                WICategory category = null;
                if (WorldItems.Get.Category(categoryName, out category))
                {
                    for (int i = 0; i < category.GenericWorldItems.Count; i++)
                    {
                        //create one for each instance
                        for (int j = 0; j < category.GenericWorldItems [i].InstanceWeight; j++)
                        {
                            gSpawnPointTransform.Position   = worlditem.tr.TransformPoint(SpawnPoints [i % SpawnPoints.Count]);
                            gSpawnPointTransform.Rotation.x = Random.Range(0f, 360f);
                            gSpawnPointTransform.Rotation.y = Random.Range(0f, 360f);
                            gSpawnPointTransform.Rotation.z = Random.Range(0f, 360f);
                            if (WorldItems.CloneWorldItem(category.GenericWorldItems [i], gSpawnPointTransform, false, WIGroups.Get.World, out gDropItem))
                            {
                                gDropItem.Props.Local.Mode = WIMode.World;
                                gDropItem.Initialize();
                                gDropItem.SetMode(WIMode.World);

                                if (!string.IsNullOrEmpty(DropEffect))
                                {
                                    FXManager.Get.SpawnFX(gDropItem, DropEffect);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                //we prefer spawn points first
                if (SpawnPoints.Count > 0)
                {
                    for (int i = 0; i < SpawnPoints.Count; i++)
                    {
                        mSpawnPoint = SpawnPoints [i];
                        if (Random.value > RandomDropout)
                        {
                            if (WorldItems.CloneRandomFromCategory(categoryName, WIGroups.Get.World, out gDropItem))                                    ////Debug.Log ("Cloning item!");
                            {
                                gDropItem.Props.Local.Transform.Position = worlditem.tr.TransformPoint(mSpawnPoint);
                                //Debug.Log ("Worlditem at position " + worlditem.tr.position + " dropping item " + gDropItem.Props.Local.Transform.Position.ToString () + " from spawn point " + mSpawnPoint.ToString());
                                gDropItem.Props.Local.Transform.Rotation.x = Random.Range(0f, 360f);
                                gDropItem.Props.Local.Transform.Rotation.y = Random.Range(0f, 360f);
                                gDropItem.Props.Local.Transform.Rotation.z = Random.Range(0f, 360f);
                                gDropItem.Props.Local.FreezeOnStartup      = false;
                                gDropItem.Props.Local.Mode = WIMode.World;
                                gDropItem.Initialize();
                                gDropItem.SetMode(WIMode.World);
                                if (!string.IsNullOrEmpty(DropEffect))
                                {
                                    FXManager.Get.SpawnFX(gDropItem, DropEffect);
                                }
                            }
                        }
                    }
                }
                else
                {
                    //if no spawn points exist, spawn stuff using mesh vertices
                    //System.Random random = new System.Random (Profile.Get.CurrentGame.Seed);
                    int      numToSpawn = UnityEngine.Random.Range(MinRandomItems, MaxRandomItems);                //random.Next (MinRandomItems, MaxRandomItems);
                    Renderer r          = null;
                    if (worlditem.HasStates)
                    {
                        r = worlditem.States.CurrentState.StateRenderer;
                    }
                    else
                    {
                        //just get the first renderer
                        r = worlditem.Renderers [0];
                    }
                    //TODO make this more safe?
                    Mesh      sharedMesh = r.GetComponent <MeshFilter> ().sharedMesh;
                    Vector3[] vertices   = sharedMesh.vertices;
                    //Debug.Log ("Spawning from " + vertices.Length.ToString () + " vertices");
                    for (int i = 0; i < numToSpawn; i++)
                    {
                        if (WorldItems.CloneRandomFromCategory(categoryName, WIGroups.Get.World, out gDropItem))
                        {
                            gDropItem.Props.Local.Transform.Position = worlditem.tr.TransformPoint(vertices [UnityEngine.Random.Range(0, vertices.Length)]);
                            //Debug.Log ("Worlditem at position " + worlditem.tr.position + " dropping item " + gDropItem.Props.Local.Transform.Position.ToString () + " from mesh spawn point " + mSpawnPoint.ToString ());
                            gDropItem.Props.Local.Transform.Rotation.x = Random.Range(0f, 360f);
                            gDropItem.Props.Local.Transform.Rotation.y = Random.Range(0f, 360f);
                            gDropItem.Props.Local.Transform.Rotation.z = Random.Range(0f, 360f);
                            gDropItem.Props.Local.FreezeOnStartup      = false;
                            gDropItem.Props.Local.Mode = WIMode.World;
                            gDropItem.Initialize();
                            gDropItem.SetMode(WIMode.World);

                            if (!string.IsNullOrEmpty(DropEffect))
                            {
                                FXManager.Get.SpawnFX(gDropItem, DropEffect);
                            }
                        }
                        else
                        {
                            Debug.Log("Couldn't clone item from category " + categoryName);
                        }
                    }
                }
            }
            Finish();
        }
Ejemplo n.º 22
0
        public static Signboard AddBar(Signboard newSign, WorldItem owner, WIGroup locationGroup, STransform offset, string textureName)
        {
            newSign = GetOrCreateSignboard(newSign, owner, locationGroup, offset, textureName, "Bar");
            switch (newSign.Style)
            {
            case SignboardStyle.A:
            default:
                Get.BarASignboards.SafeAdd(newSign);
                break;

            case SignboardStyle.B:
                Get.BarBSignboards.SafeAdd(newSign);
                break;
            }
            return(newSign);
        }
Ejemplo n.º 23
0
        public static bool GetAboveGroundSpawnPoint(ref SpawnPoint spawnPoint, SpawnerStateSetting setting, Location spawnLocation, WIGroup spawnGroup)
        {
            bool succeeded = false;

            spawnPoint = new SpawnPoint();
            switch (setting.Method)
            {
            case SpawnerPlacementMethod.SherePoint:
                //cast a ray from the center of the location outwards
                Vector3    starget = (UnityEngine.Random.onUnitSphere * spawnLocation.worlditem.ActiveRadius) + spawnLocation.worlditem.tr.position;
                Vector3    sscale  = Vector3.one;
                RaycastHit hit;
                if (Physics.Linecast(spawnLocation.worlditem.tr.position, starget, out hit, Globals.LayersTerrain))
                {
                    spawnPoint.Transform.Position = spawnLocation.worlditem.tr.InverseTransformPoint(hit.point);
                    spawnPoint.Transform.Rotation = Quaternion.FromToRotation(Vector3.up, hit.normal).eulerAngles;                     //random forward vector, normal up vector
                    spawnPoint.Transform.Scale    = sscale;
                    switch (hit.collider.gameObject.layer)
                    {
                    case Globals.LayerNumFluidTerrain:
                        spawnPoint.HitWater = true;
                        break;

                    case Globals.LayerNumSolidTerrain:
                    default:
                        spawnPoint.HitTerrainMesh = true;
                        break;
                    }
                    succeeded = true;
                }
                break;

            case SpawnerPlacementMethod.SpawnPoint:
                STransform manualPoint = null;
                if (!setting.NextManualSpawnPoint(out manualPoint))
                {
                    //whoops, we're out
                    return(false);
                }
                //no need to do any searching
                spawnPoint.Transform.CopyFrom(manualPoint);
                spawnPoint.HitWater       = false;
                spawnPoint.HitTerrainMesh = false;
                succeeded = true;
                break;

            case SpawnerPlacementMethod.TopDown:
            default:
                //get a random point in sphere scaled to the location's radius
                mTerrainHit.groundedHeight = spawnLocation.worlditem.ActiveRadius;
                mTerrainHit.feetPosition   = (UnityEngine.Random.insideUnitSphere * mTerrainHit.groundedHeight) + spawnLocation.worlditem.tr.position;
                mTerrainHit.feetPosition.y = GameWorld.Get.TerrainHeightAtInGamePosition(ref mTerrainHit);
                if (mTerrainHit.hitTerrain || mTerrainHit.hitTerrainMesh || (setting.SpawnOnStructureMeshes && mTerrainHit.hitStructureMesh))
                {
                    spawnPoint.Transform.Position = spawnLocation.worlditem.tr.InverseTransformPoint(mTerrainHit.feetPosition);
                    spawnPoint.Transform.Rotation = Quaternion.LookRotation(SVector3.Random(-1f, 1f), mTerrainHit.normal).eulerAngles;
                    spawnPoint.Transform.Scale    = Vector3.one;
                    spawnPoint.HitWater           = mTerrainHit.hitWater;
                    spawnPoint.HitTerrainMesh     = mTerrainHit.hitTerrainMesh;
                    succeeded = true;
                }
                else
                {
                    Debug.Log("SPAWNER " + spawnLocation.name + ": Failed because either didn't hit terrain (" + mTerrainHit.hitTerrain.ToString()
                              + ") or didn't hit terrain mesh (" + mTerrainHit.hitTerrainMesh.ToString()
                              + ") or can't spawn on structures (" + mTerrainHit.hitStructureMesh.ToString());
                    succeeded = false;
                }
                break;
            }
            return(succeeded);
        }
Ejemplo n.º 24
0
        protected IEnumerator SendPlayerToLocation(int chunkID, string locationPath, string locationName, STransform spawnPosition, Vector3 chunkOffset, float delay)
        {
            //save our target info for when the location loads
            mTargetSpawnPosition          = ObjectClone.Clone <STransform> (spawnPosition);
            mTargetSpawnPosition.Position = chunkOffset + mTargetSpawnPosition.Position;
            mTargetLocationName           = locationName;
            //set the primary chunk
            GameWorld.Get.SetPrimaryChunk(chunkID);
            //set all the non-distant chunks to load
            GameWorld.Get.SetDistantChunks(mTargetSpawnPosition.Position);
            while (GameWorld.Get.PrimaryChunk.CurrentMode != ChunkMode.Primary)
            {
                mLoadingInfo = "Waiting for primary chunk to load";
                //Debug.Log("Waiting for primary chunk to load");
                yield return(null);
            }
            //use a SuperLoader to load the location
            yield return(WIGroups.SuperLoadChildItem(locationPath, locationName, null, delay));

            //alright! we've found the location
            //now we can send the player to our target position and spawn
            //send the player to the target position
            yield break;
        }
Ejemplo n.º 25
0
        public static void GenerateCollider(GameObject triggerObject, WIColliderType colliderType, STransform colliderTransform)
        {
            switch (colliderType)
            {
            case WIColliderType.ConvexMesh:
                MeshCollider mcc = triggerObject.gameObject.GetOrAdd <MeshCollider>();
                mcc.sharedMesh = triggerObject.gameObject.GetOrAdd <MeshFilter>().mesh;
                mcc.convex     = true;
                break;

            case WIColliderType.Mesh:
                MeshCollider mc = triggerObject.gameObject.GetOrAdd <MeshCollider>();
                mc.sharedMesh = triggerObject.gameObject.GetOrAdd <MeshFilter>().mesh;
                mc.convex     = false;
                break;

            case WIColliderType.Box:
                BoxCollider bc = triggerObject.GetOrAdd <BoxCollider>();
                break;

            case WIColliderType.Sphere:
                SphereCollider sc = triggerObject.GetOrAdd <SphereCollider>();
                sc.radius    = colliderTransform.Scale.x;
                sc.center    = colliderTransform.Position;
                sc.isTrigger = true;
                break;

            case WIColliderType.Capsule:
                CapsuleCollider cc = triggerObject.GetOrAdd <CapsuleCollider>();
                break;

            case WIColliderType.UseExisting:
                break;

            default:
                break;
            }
        }
Ejemplo n.º 26
0
        protected IEnumerator SendPlayerToStructure(int chunkID, MobileReference locationReference, string structureName, bool interior, STransform chunkPosition, Vector3 chunkOffset)
        {
            mStartupStructure = null;
            StartCoroutine(WIGroups.SuperLoadChildItem(
                               locationReference.GroupPath,
                               locationReference.FileName,
                               StartupStructureLoaded,
                               0f));

            while (mStartupStructure == null)
            {
                yield return(null);
            }

            double startBuildTime = WorldClock.RealTime;

            mStartupStructure.LoadPriority = StructureLoadPriority.SpawnPoint;
            Structures.AddExteriorToLoad(mStartupStructure);

            while (!mStartupStructure.Is(StructureLoadState.ExteriorLoaded | StructureLoadState.InteriorLoading | StructureLoadState.InteriorLoaded))
            {
                mLoadingInfo = "Waiting for exterior to build";
                if ((WorldClock.RealTime - startBuildTime) > 60f)
                {
                    mLoadingInfo = "Exterior build timeout!";
                    yield break;
                }
                yield return(null);
            }
            Structures.AddInteriorToLoad(mStartupStructure);
            startBuildTime = WorldClock.RealTime;

            while (!mStartupStructure.Is(StructureLoadState.InteriorLoaded))
            {
                mLoadingInfo = "Waiting for interior to build";
                if ((WorldClock.RealTime - startBuildTime) > 60f)
                {
                    mLoadingInfo = "Interior build timeout!";
                    yield break;
                }
                yield return(null);
            }
            mLoadingInfo = "Interior structure is built";
            Player.Local.Surroundings.StartupStructure = mStartupStructure;

            yield return(null);

            yield break;
        }
Ejemplo n.º 27
0
    public static void Save(string name, Transform transform)
    {
        STransform item = new STransform(transform);

        DefaultSave <STransform>(name, item);
    }