Пример #1
0
        /// <summary>
        /// Processes the disposed controllers, joints, springs, bodies and cleans up the arbiter list.
        /// </summary>
        private void ProcessDisposedItems()
        {
            //Allow each controller to validate itself. this is where a controller can Dispose of itself if need be.
            for (int i = 0; i < ControllerList.Count; i++)
            {
                ControllerList[i].Validate();
            }

            //Allow each joint to validate itself. this is where a joint can Dispose of itself if need be.
            for (int i = 0; i < JointList.Count; i++)
            {
                JointList[i].Validate();
            }

            //Allow each spring to validate itself. this is where a spring can Dispose of itself if need be.
            for (int i = 0; i < SpringList.Count; i++)
            {
                SpringList[i].Validate();
            }

            _tempCount = GeomList.RemoveDisposed();

            if (_tempCount > 0)
            {
                _broadPhaseCollider.ProcessDisposedGeoms();
            }

            BodyList.RemoveDisposed();
            ControllerList.RemoveDisposed();
            SpringList.RemoveDisposed();
            JointList.RemoveDisposed();

            //Clean up the arbiterlist
            ArbiterList.CleanArbiterList(arbiterPool);
        }
Пример #2
0
    public static void LoadBodiesInGame(BodyList bodylist)
    {
        foreach (DataBody db in bodylist.bodies)
        {
            if (db.reserved)
            {
                continue;
            }

            GameObject g = new GameObject(db.bodyName);
            Body       b = g.AddComponent <Body>();
            b.pack      = db.pack;
            b.author    = db.author;
            b.bodyName  = db.bodyName;
            b.bodyClass = db.bodyClass;
            b.soi       = db.soi;
            b.position  = db.position;

            //GameBody gb = g.AddComponent<GameBody>();
            //b.gameBody = gb;

            g.transform.position   = new Vector3(b.position.x, b.position.z, b.position.y);
            g.transform.localScale = Vector3.one * 0.2f;
            DisplaySOI soi = g.AddComponent <DisplaySOI>();
            soi.SphereOfInfluence = db.soi;

            SpriteRenderer sr = g.AddComponent <SpriteRenderer>();
            b.spriteRenderer = sr;
        }
    }
Пример #3
0
        void GetWaferStatus(BodyList body)
        {
            var temp = body.ToArray();
            var key  = body.ElementAt(0);

            string res;

            if (WfNow.WaferCreateTime == key)
            {
                res = "GetWaferStatus" +
                      WfNow.WaferCreateTime.AddBar() +
                      WfNow.WaferName.AddBar() +
                      WfStatus.ToString().AddBar();
            }
            else if (WfInfoList.Select(x => x.WaferCreateTime).Contains(key))
            {
                var result = WfInfoList.Where(x => x.WaferCreateTime == key).First();

                res = "GetWaferStatus" +
                      key.AddBar() +
                      result.WaferName.AddBar() +
                      "Wait".AddBar();
            }
            else
            {
                res = "TBD";
            }
            ProcClient.SendMsg(res.WithCount());
        }
Пример #4
0
        private void ConstructPhysicsSimulator(Vector2 gravity)
        {
            geomList       = new GeomList();
            geomAddList    = new List <Geom>();
            geomRemoveList = new List <Geom>();

            bodyList       = new BodyList();
            bodyAddList    = new List <Body>();
            bodyRemoveList = new List <Body>();

            controllerList       = new ControllerList();
            controllerAddList    = new List <Controller>();
            controllerRemoveList = new List <Controller>();

            jointList       = new JointList();
            jointAddList    = new List <Joint>();
            jointRemoveList = new List <Joint>();

            _broadPhaseCollider = new SelectiveSweepCollider(this);

            arbiterList = new ArbiterList();
            _gravity    = gravity;

            arbiterPool = new Pool <Arbiter>(_arbiterPoolSize);

            #region Added by Daniel Pramel 08/17/08

            _inactivityController = new InactivityController(this);

            _scaling = new Scaling(0.001f, 0.01f);

            #endregion
        }
Пример #5
0
        /// <summary>
        /// Destroy a rigid body.
        /// Warning: This function is locked during callbacks.
        /// Warning: This automatically deletes all associated shapes and joints.
        /// </summary>
        /// <param name="body">The body.</param>
        public void RemoveBody(Body body)
        {
            Debug.Assert(BodyList.Count > 0);
            Debug.Assert(!IsLocked);

            if (IsLocked)
            {
                return;
            }

            // You tried to remove a body that is not contained in the BodyList.
            // Are you removing the body more than once?
            Debug.Assert(BodyList.Contains(body));

            // Delete the attached joints.
            JointEdge je = body.JointList;

            while (je != null)
            {
                JointEdge je0 = je;
                je = je.Next;

                RemoveJoint(je0.Joint);
            }
            body.JointList = null;

            // Delete the attached contacts.
            ContactEdge ce = body.ContactList;

            while (ce != null)
            {
                ContactEdge ce0 = ce;
                ce = ce.Next;
                ContactManager.Destroy(ce0.Contact);
            }
            body.ContactList = null;

            // Delete the attached fixtures. This destroys broad-phase proxies.

            foreach (Fixture fixture in body.FixtureList)
            {
                fixture.DestroyProxies(ContactManager.BroadPhase);
                fixture.Destroy();
            }

            body.FixtureList = null;

            // Remove world body list.
            BodyList.Remove(body);

            if (BodyRemoved != null)
            {
                BodyRemoved(body);
            }
        }
Пример #6
0
        private void ProcessRemovedBodies()
        {
            if (_bodyRemoveList.Count > 0)
            {
                foreach (Body body in _bodyRemoveList)
                {
                    Debug.Assert(BodyList.Count > 0);

                    // You tried to remove a body that is not contained in the BodyList.
                    // Are you removing the body more than once?
                    //Debug.Assert(BodyList.Contains(body));
                    if (!BodyList.Contains(body))
                    {
                        continue;
                    }

                    // Delete the attached joints.
                    foreach (Joint j in body.JointList)
                    {
                        RemoveJoint(j, false);
                    }
                    body.JointList.Clear();

                    // Delete the attached contacts.
                    ContactEdge ce = body.ContactList;
                    while (ce != null)
                    {
                        ContactEdge ce0 = ce;
                        ce = ce.Next;
                        ContactManager.Destroy(ce0.Contact);
                    }
                    body.ContactList = null;

                    // Delete the attached fixtures. This destroys broad-phase proxies.
                    for (int i = 0; i < body.FixtureList.Count; i++)
                    {
                        body.FixtureList[i].DestroyProxies(ContactManager.BroadPhase);
                        body.FixtureList[i].Destroy();
                    }

                    body.FixtureList = null;

                    // Remove world body list.
                    BodyList.Remove(body);

                    if (BodyRemoved != null)
                    {
                        BodyRemoved(body);
                    }
                }

                _bodyRemoveList.Clear();
            }
        }
Пример #7
0
        private void ProcessRemovedBodies()
        {
            if (_bodyRemoveList.Count > 0)
            {
                foreach (Body body in _bodyRemoveList)
                {
                    System.Diagnostics.Debug.Assert(BodyList.Count > 0);

                    // You tried to remove a body that is not contained in the BodyList.
                    // Are you removing the body more than once?
                    //Debug.Assert(BodyList.Contains(body));

                    // Delete the attached joints.
                    JointEdge je = body.JointList;
                    while (je != null)
                    {
                        JointEdge je0 = je;
                        je = je.Next;

                        RemoveJoint(je0.Joint, false);
                    }
                    body.JointList = null;

                    // Delete the attached contacts.
                    ContactEdge ce = body.ContactList;
                    while (ce != null)
                    {
                        ContactEdge ce0 = ce;
                        ce = ce.Next;
                        ContactManager.Destroy(ce0.Contact);
                    }
                    body.ContactList = null;

                    // Delete the attached fixtures. This destroys broad-phase proxies.
                    if (body.FixtureList != null)
                    {
                        for (int i = 0; i < body.FixtureList.Count; i++)
                        {
                            body.FixtureList[i].DestroyProxies(ContactManager.BroadPhase);
                            body.FixtureList[i].Destroy();
                        }
                    }

                    body.FixtureList = null;

                    // Remove world body list.
                    BodyList.Remove(body);

                    BodyRemoved?.Invoke(body);
                }

                _bodyRemoveList.Clear();
            }
        }
Пример #8
0
 void RemoveWafer(BodyList body)
 {
     try
     {
         var key = body.ElementAt(0);
         WfInfoList = new Queue <WfInfo>(WfInfoList.Where(x => x.WaferCreateTime != key));
     }
     catch (Exception)
     {
         ProcClient.SendMsg("TBD");
     }
 }
Пример #9
0
 public QuadTreeNode(BodyList bodies,
                     int bodyLimit,
                     int maxDepth,
                     Vector2 bounds)
     : this(bodies,
            bodyLimit,
            maxDepth,
            0,
            bounds * 0.5f,
            bounds)
 {
 }
Пример #10
0
        private float _width; // width and height of bodies to create

        /// <summary>
        /// Initializes a new instance of the <see cref="Path"/> class.
        /// </summary>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="mass">The mass.</param>
        /// <param name="endless">if set to <c>true</c> [endless].</param>
        public Path(float width, float height, float mass, bool endless)
        {
            _width = width;
            _height = height;
            _loop = endless;
            _mass = mass;
            _geoms = new GeomList();
            _bodies = new BodyList();
            _joints = new JointList();
            _springs = new SpringList();
            _controlPoints = new Vertices();
        }
Пример #11
0
        private void ProcessAddedBodies()
        {
            foreach (Body body in _bodyAddList)
            {
                // Add to world list.
                BodyList.Add(body);

                if (BodyAdded != null)
                {
                    BodyAdded(body);
                }
            }

            _bodyAddList.Clear();
        }
Пример #12
0
        private void ProcessAddedBodies()
        {
            for (int i = 0; i < _bodyAddList.Count; i++)
            {
                // Add to world list.
                BodyList.Add(_bodyAddList[i]);

                if (BodyAdded != null)
                {
                    BodyAdded(_bodyAddList[i]);
                }
            }

            _bodyAddList.Clear();
        }
Пример #13
0
        private void ProcessAddedBodies()
        {
            if (_bodyAddList.Count > 0)
            {
                foreach (var body in _bodyAddList)
                {
                    // Add to world list.
                    BodyList.Add(body);

                    BodyAdded?.Invoke(body);
                }

                _bodyAddList.Clear();
            }
        }
Пример #14
0
        /// <summary>
        /// Creates new instance of <see cref="QuadTree"/> using given configuration.
        /// </summary>
        /// <param name="bodies">body list this tree is presenting</param>
        /// <param name="nodeBodyLimit">max body limit for each node before split occurs</param>
        /// <param name="maxDepth">max depth in nodes</param>
        /// <param name="bounds">bounds of the tree</param>
        public QuadTree(BodyList bodies, int nodeBodyLimit, int maxDepth, Vector2 bounds)
        {
            if (nodeBodyLimit < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(nodeBodyLimit));
            }

            if (maxDepth < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(maxDepth));
            }

            Root        = new QuadTreeNode(bodies, nodeBodyLimit, maxDepth, bounds);
            BoundingBox = new Aabb(bounds * 0.5f, bounds * 0.5f);
            active      = new HashSet <int>(InitialBodyBufferCapacity);
        }
Пример #15
0
 public virtual void Clear()
 {
     Header.ElementFormat.Ver      = 2.1f;
     Header.ElementFormat.UVACount = 0;
     ModelInfo.Clear();
     VertexList.Clear();
     FaceList.Clear();
     MaterialList.Clear();
     BoneList.Clear();
     MorphList.Clear();
     BodyList.Clear();
     JointList.Clear();
     SoftBodyList.Clear();
     InitializeSystemNode();
     FilePath     = "";
     LoadErrCount = 0;
 }
Пример #16
0
        public AgentDeclarationNode(string name, ArgumentList args, List <INode> body)
            : base(name, args, new List <INode>())
        {
            this.beliefDeclarations = new List <BeliefDeclarationNode>();

            foreach (var node in body)
            {
                var belief = node as BeliefDeclarationNode;
                if (belief != null)
                {
                    beliefDeclarations.Add(belief);
                }
                else
                {
                    BodyList.Add(node);
                }
            }
        }
Пример #17
0
        /// <summary>
        /// Create a rigid body.
        /// Warning: This function is locked during callbacks.
        /// </summary>
        /// <returns></returns>
        public Body CreateBody()
        {
            Debug.Assert(!IsLocked);
            if (IsLocked)
            {
                return(null);
            }

            Body body = new Body(this);

            // Add to world doubly linked list.
            BodyList.Add(body);

            if (BodyAdded != null)
            {
                BodyAdded(body);
            }

            return(body);
        }
Пример #18
0
    public void LoadBodies(String json)
    {
        try
        {
            Body.DestroyAllBodies();
            Body.bodies.Clear();

            BodyList bl = JSONLoader.LoadStars(json);
            DataBody.LoadBodiesInGame(bl);

            GameObject tempParentGo = GameObject.Find("Bodies");
            foreach (GameObject go in Body.bodies)
            {
                go.transform.SetParent(tempParentGo.transform);
            }
        }
        catch (Exception e)
        {
            Logger.Error("Exception while loading: " + e);
        }
    }
Пример #19
0
        public async Task <IActionResult> Index2()
        {
            var bodyAbility = from bb in _context.BodyAbility select bb;

            bodyAbility = bodyAbility.Where(m => m.user_id == User.Identity.Name);
            List <BodyAbility> b = await bodyAbility.OrderBy(m => m.create_time).AsNoTracking().ToListAsync();

            var lastAbilit = await _context.BodyAbility.OrderBy(m => m.create_time).LastOrDefaultAsync(m => m.user_id == User.Identity.Name);

            BodyList list = new BodyList();

            list.alllist  = b;
            list.lastlist = lastAbilit;

            foreach (var x in b)
            {
                list.time.Add(x.create_time.ToString("MM-dd"));
                list.bfp.Add(x.bfp.ToString());
                list.bmi.Add(x.bmi.ToString());
            }
            return(View(list));
        }
Пример #20
0
        /// <summary>
        /// Creates new instance of <see cref="QuadTreeNode"/> with
        /// given configuration.
        /// </summary>
        /// <param name="bodies">list containing body data</param>
        /// <param name="bodyLimit">limit of bodies before split occurs</param>
        /// <param name="maxDepth">max depth of the tree in nodes</param>
        /// <param name="depth">current depth of the tree and this node</param>
        /// <param name="center">center position of the node</param>
        /// <param name="bounds">bounds of the node</param>
        public QuadTreeNode(BodyList bodies,
                            int bodyLimit,
                            int maxDepth,
                            int depth,
                            Vector2 center,
                            Vector2 bounds)
        {
            boundingBox = new Aabb(center, bounds * 0.5f);

            this.bodies    = bodies ?? throw new ArgumentNullException(nameof(bodies));
            this.bodyLimit = bodyLimit;
            this.maxDepth  = maxDepth;

            Depth = depth;

            // Create body lists.
            bodyLists = new List <int> [QuadTreeNodeLink.ListsCount];

            for (var i = 0; i < bodyLists.Length; i++)
            {
                bodyLists[i] = new List <int>();
            }
        }
Пример #21
0
        private void ConstructPhysicsSimulator(Vector2 gravity)
        {
            geomList = new GeomList();
            geomAddList = new List<Geom>();
            geomRemoveList = new List<Geom>();

            bodyList = new BodyList();
            bodyAddList = new List<Body>();
            bodyRemoveList = new List<Body>();

            controllerList = new ControllerList();
            controllerAddList = new List<Controller>();
            controllerRemoveList = new List<Controller>();

            jointList = new JointList();
            jointAddList = new List<Joint>();
            jointRemoveList = new List<Joint>();

            springList = new SpringList();
            springAddList = new List<Spring>();
            springRemoveList = new List<Spring>();

            _broadPhaseCollider = new SelectiveSweepCollider(this);

            arbiterList = new ArbiterList();
            _gravity = gravity;

            arbiterPool = new Pool<Arbiter>(_arbiterPoolSize);

            #region Added by Daniel Pramel 08/17/08

            _inactivityController = new InactivityController(this);

            _scaling = new Scaling(0.001f, 0.01f);

            #endregion
        }
            protected override void OnReload(GameMode currentGameMode)
            {
                BodyGUID     = null;
                PenisGUID    = null;
                BallsGUID    = null;
                DisplayPenis = ChaControl.sex == 0;
                DisplayBalls = ChaControl.sex == 0;

                var data = GetExtendedData();

                if (data != null)
                {
                    if (data.version == 1)
                    {
                        if (data.data.TryGetValue("DisplayBalls", out var loadedDisplayBalls))
                        {
                            DisplayBalls = (bool)loadedDisplayBalls;
                        }
                        if (data.data.TryGetValue("UncensorGUID", out var loadedUncensorGUID) && loadedUncensorGUID != null)
                        {
                            string UncensorGUID = loadedUncensorGUID.ToString();
                            if (!UncensorGUID.IsNullOrWhiteSpace() && MigrationDictionary.TryGetValue(UncensorGUID, out MigrationData migrationData))
                            {
                                BodyGUID  = migrationData.BodyGUID;
                                PenisGUID = migrationData.PenisGUID;
                                BallsGUID = migrationData.BallsGUID;
                                if (PenisGUID != null)
                                {
                                    DisplayPenis = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (data.data.TryGetValue("BodyGUID", out var loadedUncensorGUID) && loadedUncensorGUID != null)
                        {
                            BodyGUID = loadedUncensorGUID.ToString();
                        }

                        if (data.data.TryGetValue("PenisGUID", out var loadedPenisGUID) && loadedPenisGUID != null)
                        {
                            PenisGUID = loadedPenisGUID.ToString();
                        }

                        if (data.data.TryGetValue("BallsGUID", out var loadedBallsGUID) && loadedBallsGUID != null)
                        {
                            BallsGUID = loadedBallsGUID.ToString();
                        }

                        if (data.data.TryGetValue("DisplayPenis", out var loadedDisplayPenis))
                        {
                            DisplayPenis = (bool)loadedDisplayPenis;
                        }

                        if (data.data.TryGetValue("DisplayBalls", out var loadedDisplayBalls))
                        {
                            DisplayBalls = (bool)loadedDisplayBalls;
                        }
                    }
                }

                if (BodyGUID.IsNullOrWhiteSpace())
                {
                    BodyGUID = null;
                }
                if (PenisGUID.IsNullOrWhiteSpace())
                {
                    PenisGUID = null;
                }
                if (BallsGUID.IsNullOrWhiteSpace())
                {
                    BallsGUID = null;
                }

                if (MakerAPI.InsideAndLoaded)
                {
                    DoDropdownEvents = false;
                    if (MakerAPI.GetCharacterLoadFlags().Body)
                    {
                        if (MakerAPI.GetMakerBase().chaCtrl == ChaControl)
                        {
                            //Update the UI to match the loaded character
                            if (BodyGUID == null || BodyList.IndexOf(BodyGUID) == -1)
                            {
                                //The loaded uncensor isn't on the list, possibly due to being forbidden
                                BodyDropdown.Value = 0;
                                BodyGUID           = null;
                            }
                            else
                            {
                                BodyDropdown.Value = BodyList.IndexOf(BodyGUID);
                            }

                            if (PenisGUID == null || PenisList.IndexOf(PenisGUID) == -1)
                            {
                                PenisDropdown.Value = DisplayPenis ? 0 : 1;
                                PenisGUID           = null;
                            }
                            else
                            {
                                PenisDropdown.Value = PenisList.IndexOf(PenisGUID);
                            }

                            if (BallsGUID == null || BallsList.IndexOf(BallsGUID) == -1)
                            {
                                BallsDropdown.Value = DisplayBalls ? 0 : 1;
                                BallsGUID           = null;
                            }
                            else
                            {
                                BallsDropdown.Value = BallsList.IndexOf(BallsGUID);
                            }
                        }
                    }
                    else
                    {
                        //Set the uncensor stuff to whatever is set in the maker
                        BodyGUID     = BodyDropdown.Value == 0 ? null : BodyList[BodyDropdown.Value];
                        PenisGUID    = PenisDropdown.Value == 0 || PenisDropdown.Value == 1 ? null : PenisList[PenisDropdown.Value];
                        BallsGUID    = BallsDropdown.Value == 0 || BallsDropdown.Value == 1 ? null : BallsList[BallsDropdown.Value];
                        DisplayPenis = PenisDropdown.Value == 1 ? false : true;
                        DisplayBalls = BallsDropdown.Value == 1 ? false : true;
                    }
                    DoDropdownEvents = true;
                }
                //Update the uncensor on every load or reload
                UpdateUncensor();
            }
 public void PopBody(Body tgtBody)
 {
     // Add Body to BodyList
     BodyList.Remove(tgtBody);
     _nBodies -= 1;
 }
 public void AddBody(Body newBody)
 {
     // Add Body to BodyList
     BodyList.Add(newBody);
     _nBodies += 1;
 }
Пример #25
0
 void AddWafer(BodyList body)
 => WfInfoList.Enqueue(body.ToWfInfo());
Пример #26
0
        /// <summary>
        /// Processes the added geometries, springs, joints, bodies and controllers.
        /// </summary>
        private void ProcessAddedItems()
        {
            //Add any new geometries
            _tempCount = _geomAddList.Count;
            for (int i = 0; i < _tempCount; i++)
            {
                if (!GeomList.Contains(_geomAddList[i]))
                {
                    _geomAddList[i].InSimulation = true;
                    GeomList.Add(_geomAddList[i]);

                    //Add the new geometry to the broad phase collider.
                    _broadPhaseCollider.Add(_geomAddList[i]);
                }
            }
            _geomAddList.Clear();

            //Add any new bodies
            _tempCount = _bodyAddList.Count;
            for (int i = 0; i < _tempCount; i++)
            {
                if (!BodyList.Contains(_bodyAddList[i]))
                {
                    BodyList.Add(_bodyAddList[i]);
                }
            }
            _bodyAddList.Clear();

            //Add any new controllers
            _tempCount = _controllerAddList.Count;
            for (int i = 0; i < _tempCount; i++)
            {
                if (!ControllerList.Contains(_controllerAddList[i]))
                {
                    ControllerList.Add(_controllerAddList[i]);
                }
            }
            _controllerAddList.Clear();

            //Add any new joints
            _tempCount = _jointAddList.Count;
            for (int i = 0; i < _tempCount; i++)
            {
                if (!JointList.Contains(_jointAddList[i]))
                {
                    JointList.Add(_jointAddList[i]);
                }
            }
            _jointAddList.Clear();

            //Add any new springs
            _tempCount = _springAddList.Count;
            for (int i = 0; i < _tempCount; i++)
            {
                if (!SpringList.Contains(_springAddList[i]))
                {
                    SpringList.Add(_springAddList[i]);
                }
            }
            _springAddList.Clear();
        }
Пример #27
0
        public virtual void FromStream(Stream s, bool id)
        {
            Action <Action> action = delegate(Action a)
            {
                try
                {
                    a();
                }
                catch (Exception)
                {
                    LoadErrCount++;
                }
            };
            PmxHeader head = new PmxHeader();

            head.FromStreamEx(s);
            Header.FromHeader(head);
            head.ElementFormat.WithID = id;
            action(delegate
            {
                ModelInfo.FromStreamEx(s, head.ElementFormat);
            });
            int count = 0;

            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            VertexList.Clear();
            VertexList.Capacity = count;
            for (int k = 0; k < count; k++)
            {
                PmxVertex v = new PmxVertex();
                action(delegate
                {
                    v.FromStreamEx(s, head.ElementFormat);
                });
                VertexList.Add(v);
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            FaceList.Clear();
            FaceList.Capacity = count;
            for (int l = 0; l < count; l++)
            {
                int ix = 0;
                action(delegate
                {
                    ix = PmxStreamHelper.ReadElement_Int32(s, head.ElementFormat.VertexSize, signed: false);
                });
                FaceList.Add(ix);
            }
            PmxTextureTable tx = new PmxTextureTable();

            action(delegate
            {
                tx.FromStreamEx(s, head.ElementFormat);
            });
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            MaterialList.Clear();
            MaterialList.Capacity = count;
            for (int m = 0; m < count; m++)
            {
                PmxMaterial j = new PmxMaterial();
                action(delegate
                {
                    j.FromStreamEx_TexTable(s, tx, head.ElementFormat);
                });
                MaterialList.Add(j);
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            BoneList.Clear();
            BoneList.Capacity = count;
            for (int n = 0; n < count; n++)
            {
                PmxBone b = new PmxBone();
                action(delegate
                {
                    b.FromStreamEx(s, head.ElementFormat);
                });
                BoneList.Add(b);
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            MorphList.Clear();
            MorphList.Capacity = count;
            for (int num = 0; num < count; num++)
            {
                PmxMorph morph = new PmxMorph();
                action(delegate
                {
                    morph.FromStreamEx(s, head.ElementFormat);
                });
                MorphList.Add(morph);
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            NodeList.Clear();
            NodeList.Capacity = count;
            for (int num2 = 0; num2 < count; num2++)
            {
                PmxNode node = new PmxNode();
                action(delegate
                {
                    node.FromStreamEx(s, head.ElementFormat);
                });
                NodeList.Add(node);
                if (NodeList[num2].SystemNode)
                {
                    if (NodeList[num2].Name == "Root")
                    {
                        RootNode = NodeList[num2];
                    }
                    else if (NodeList[num2].Name == "表情")
                    {
                        ExpNode = NodeList[num2];
                    }
                }
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            BodyList.Clear();
            BodyList.Capacity = count;
            for (int num3 = 0; num3 < count; num3++)
            {
                PmxBody b2 = new PmxBody();
                action(delegate
                {
                    b2.FromStreamEx(s, head.ElementFormat);
                });
                BodyList.Add(b2);
            }
            action(delegate
            {
                count = PmxStreamHelper.ReadElement_Int32(s);
            });
            JointList.Clear();
            JointList.Capacity = count;
            for (int num4 = 0; num4 < count; num4++)
            {
                PmxJoint i = new PmxJoint();
                action(delegate
                {
                    i.FromStreamEx(s, head.ElementFormat);
                });
                JointList.Add(i);
            }
            if (head.Ver >= 2.1f)
            {
                action(delegate
                {
                    count = PmxStreamHelper.ReadElement_Int32(s);
                });
                SoftBodyList.Clear();
                SoftBodyList.Capacity = count;
                for (int num5 = 0; num5 < count; num5++)
                {
                    PmxSoftBody b3 = new PmxSoftBody();
                    action(delegate
                    {
                        b3.FromStreamEx(s, head.ElementFormat);
                    });
                    SoftBodyList.Add(b3);
                }
            }
            if (id)
            {
                action(delegate
                {
                    FilePath = PmxStreamHelper.ReadString(s, head.ElementFormat);
                });
            }
            head.ElementFormat.WithID = false;
        }
Пример #28
0
        public void FromPmx(Pmx pmx)
        {
            Clear();
            FilePath     = pmx.FilePath;
            LoadErrCount = pmx.LoadErrCount;
            Header       = pmx.Header.Clone();
            ModelInfo    = pmx.ModelInfo.Clone();
            int count = pmx.VertexList.Count;

            VertexList.Capacity = count;
            for (int i = 0; i < count; i++)
            {
                VertexList.Add(pmx.VertexList[i].Clone());
            }
            count             = pmx.FaceList.Count;
            FaceList.Capacity = count;
            for (int j = 0; j < count; j++)
            {
                FaceList.Add(pmx.FaceList[j]);
            }
            count = pmx.MaterialList.Count;
            MaterialList.Capacity = count;
            for (int k = 0; k < count; k++)
            {
                MaterialList.Add(pmx.MaterialList[k].Clone());
            }
            count             = pmx.BoneList.Count;
            BoneList.Capacity = count;
            for (int l = 0; l < count; l++)
            {
                BoneList.Add(pmx.BoneList[l].Clone());
            }
            count = pmx.MorphList.Count;
            MorphList.Capacity = count;
            for (int m = 0; m < count; m++)
            {
                MorphList.Add(pmx.MorphList[m].Clone());
            }
            count = pmx.NodeList.Count;
            NodeList.Clear();
            NodeList.Capacity = count;
            for (int n = 0; n < count; n++)
            {
                NodeList.Add(pmx.NodeList[n].Clone());
                if (NodeList[n].SystemNode)
                {
                    if (NodeList[n].Name == "Root")
                    {
                        RootNode = NodeList[n];
                    }
                    else if (NodeList[n].Name == "表情")
                    {
                        ExpNode = NodeList[n];
                    }
                }
            }
            count             = pmx.BodyList.Count;
            BodyList.Capacity = count;
            for (int num = 0; num < count; num++)
            {
                BodyList.Add(pmx.BodyList[num].Clone());
            }
            count = pmx.JointList.Count;
            JointList.Capacity = count;
            for (int num2 = 0; num2 < count; num2++)
            {
                JointList.Add(pmx.JointList[num2].Clone());
            }
            count = pmx.SoftBodyList.Count;
            SoftBodyList.Capacity = count;
            for (int num3 = 0; num3 < count; num3++)
            {
                SoftBodyList.Add(pmx.SoftBodyList[num3].Clone());
            }
        }
Пример #29
0
 public static BodyList LoadStars(string json)
 {
     return(bodyList = JsonUtility.FromJson <BodyList>(json));
 }
Пример #30
0
        /// <summary>
        /// Processes the removed geometries (and their arbiters), bodies, controllers, joints and springs.
        /// </summary>
        private void ProcessRemovedItems()
        {
            //Remove any new geometries
            _tempCount = _geomRemoveList.Count;
            for (int i = 0; i < _tempCount; i++)
            {
                _geomRemoveList[i].InSimulation = false;
                GeomList.Remove(_geomRemoveList[i]);

                //Remove any arbiters associated with the geometries being removed
                for (int j = ArbiterList.Count; j > 0; j--)
                {
                    if (ArbiterList[j - 1].GeometryA == _geomRemoveList[i] ||
                        ArbiterList[j - 1].GeometryB == _geomRemoveList[i])
                    {
                        //TODO: Should we create a RemoveComplete method and remove all Contacts associated
                        //with the arbiter?
                        arbiterPool.Insert(ArbiterList[j - 1]);
                        ArbiterList.Remove(ArbiterList[j - 1]);
                    }
                }
            }

            if (_geomRemoveList.Count > 0)
            {
                _broadPhaseCollider.ProcessRemovedGeoms();
            }

            _geomRemoveList.Clear();

            //Remove any new bodies
            _tempCount = _bodyRemoveList.Count;
            for (int i = 0; i < _tempCount; i++)
            {
                BodyList.Remove(_bodyRemoveList[i]);
            }
            _bodyRemoveList.Clear();

            //Remove any new controllers
            _tempCount = _controllerRemoveList.Count;
            for (int i = 0; i < _tempCount; i++)
            {
                ControllerList.Remove(_controllerRemoveList[i]);
            }
            _controllerRemoveList.Clear();

            //Remove any new joints
            int jointRemoveCount = _jointRemoveList.Count;

            for (int i = 0; i < jointRemoveCount; i++)
            {
                JointList.Remove(_jointRemoveList[i]);
            }
            _jointRemoveList.Clear();

            //Remove any new springs
            _tempCount = _springRemoveList.Count;
            for (int i = 0; i < _tempCount; i++)
            {
                SpringList.Remove(_springRemoveList[i]);
            }
            _springRemoveList.Clear();
        }
            protected override void OnReload(GameMode currentGameMode, bool maintainState)
            {
                BodyGUID     = null;
                PenisGUID    = null;
                BallsGUID    = null;
                DisplayPenis = ChaControl.sex == 0;
                DisplayBalls = ChaControl.sex == 0 ? true : DefaultFemaleDisplayBalls.Value;

                var data = GetExtendedData();

                if (data != null)
                {
                    if (data.version == 1)
                    {
                        if (data.data.TryGetValue("DisplayBalls", out var loadedDisplayBalls))
                        {
                            DisplayBalls = (bool)loadedDisplayBalls;
                        }
                        if (data.data.TryGetValue("UncensorGUID", out var loadedUncensorGUID) && loadedUncensorGUID != null)
                        {
                            string UncensorGUID = loadedUncensorGUID.ToString();
                            if (!UncensorGUID.IsNullOrWhiteSpace() && MigrationDictionary.TryGetValue(UncensorGUID, out MigrationData migrationData))
                            {
                                BodyGUID  = migrationData.BodyGUID;
                                PenisGUID = migrationData.PenisGUID;
                                BallsGUID = migrationData.BallsGUID;
                                if (PenisGUID != null)
                                {
                                    DisplayPenis = true;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (data.data.TryGetValue("BodyGUID", out var loadedUncensorGUID) && loadedUncensorGUID != null)
                        {
                            BodyGUID = loadedUncensorGUID.ToString();
                        }

                        if (data.data.TryGetValue("PenisGUID", out var loadedPenisGUID) && loadedPenisGUID != null)
                        {
                            PenisGUID = loadedPenisGUID.ToString();
                        }

                        if (data.data.TryGetValue("BallsGUID", out var loadedBallsGUID) && loadedBallsGUID != null)
                        {
                            BallsGUID = loadedBallsGUID.ToString();
                        }

                        if (data.data.TryGetValue("DisplayPenis", out var loadedDisplayPenis))
                        {
                            DisplayPenis = (bool)loadedDisplayPenis;
                        }

                        if (data.data.TryGetValue("DisplayBalls", out var loadedDisplayBalls))
                        {
                            DisplayBalls = (bool)loadedDisplayBalls;
                        }
                    }
                }

                if (BodyGUID.IsNullOrWhiteSpace())
                {
                    BodyGUID = null;
                }
                if (PenisGUID.IsNullOrWhiteSpace())
                {
                    PenisGUID = null;
                }
                if (BallsGUID.IsNullOrWhiteSpace())
                {
                    BallsGUID = null;
                }

                if (MakerAPI.InsideAndLoaded)
                {
                    if (MakerAPI.GetCharacterLoadFlags().Body)
                    {
                        if (MakerAPI.GetMakerBase().chaCtrl == ChaControl)
                        {
                            //Update the UI to match the loaded character
                            if (BodyGUID == null || BodyList.IndexOf(BodyGUID) == -1)
                            {
                                //The loaded uncensor isn't on the list, possibly due to being forbidden
                                BodyDropdown.SetValue(0, false);
                                BodyGUID = null;
                            }
                            else
                            {
                                BodyDropdown.SetValue(BodyList.IndexOf(BodyGUID), false);
                            }

                            if (PenisGUID == null || PenisList.IndexOf(PenisGUID) == -1)
                            {
#if KK
                                PenisDropdown.SetValue(DisplayPenis ? 0 : 1, false);
#elif EC
                                PenisDropdown.SetValue(0, false);
#endif
                                PenisGUID = null;
                            }
                            else
                            {
                                PenisDropdown.SetValue(PenisList.IndexOf(PenisGUID), false);
                            }

                            if (BallsGUID == null || BallsList.IndexOf(BallsGUID) == -1)
                            {
                                BallsDropdown.SetValue(DisplayBalls ? 0 : 1, false);
                                BallsGUID = null;
                            }
                            else
                            {
                                BallsDropdown.SetValue(BallsList.IndexOf(BallsGUID), false);
                            }
                        }
                    }
                    else
                    {
                        //Set the uncensor stuff to whatever is set in the maker
                        BodyGUID = BodyDropdown.Value == 0 ? null : BodyList[BodyDropdown.Value];
#if KK
                        PenisGUID    = PenisDropdown.Value == 0 || PenisDropdown.Value == 1 ? null : PenisList[PenisDropdown.Value];
                        DisplayPenis = PenisDropdown.Value == 1 ? false : true;
#elif EC
                        PenisGUID = PenisDropdown.Value == 0 ? null : PenisList[PenisDropdown.Value];
#endif
                        BallsGUID    = BallsDropdown.Value == 0 || BallsDropdown.Value == 1 ? null : BallsList[BallsDropdown.Value];
                        DisplayBalls = BallsDropdown.Value == 1 ? false : true;
                    }
                }

#if KK
                //Correct characters if genderbender is not permitted, except in Studio where it may be required for scene compatibility
                if (GenderBender.Value == false && !StudioAPI.InsideStudio)
                {
                    DisplayPenis = ChaControl.sex == 0;
                    DisplayBalls = ChaControl.sex == 0;
                }
#endif

                //Update the uncensor on every load or reload
                UpdateUncensor();
            }
Пример #32
0
 public HVCTrackingResult()
 {
     this.faces  = new FaceList();
     this.bodies = new BodyList();
     this.hands  = new HandList();
 }