public virtual void UpdateJoints() { if (_info.isLocked()) { return; } CCPhysicsJoint[] addCopy = new CCPhysicsJoint[_delayAddJoints.Count]; _delayAddJoints.CopyTo(addCopy); _delayAddJoints.Clear(); foreach (var joint in addCopy) { DoAddJoint(joint); } CCPhysicsJoint[] removeCopy = new CCPhysicsJoint[_delayRemoveJoints.Count]; _delayRemoveJoints.CopyTo(removeCopy); _delayRemoveJoints.Clear(); foreach (var joint in removeCopy) { DoRemoveJoint(joint); if (joint._destoryMark) { //delete joint; } } }
public CCPhysicsJointInfo(CCPhysicsJoint joint) { _joints = new List <cpConstraint>(); _map = new Dictionary <cpConstraint, CCPhysicsJointInfo>(); _joint = joint; }
public CCPhysicsJointInfo(CCPhysicsJoint joint) { _joints = new List<cpConstraint>(); _map = new Dictionary<cpConstraint, CCPhysicsJointInfo>(); _joint = joint; }
public virtual void DoAddJoint(CCPhysicsJoint joint) { if (joint == null || joint._info == null) { return; } _info.AddJoint(joint._info); }
public void RemoveJoint(CCPhysicsJoint joint) { int it = _joints.FindIndex((j) => j == joint); if (it != -1) { _joints.RemoveAt(it); } }
public void RemoveJoint(CCPhysicsJoint joint) { var it = _joints.Find((j) => j == joint); if (it != null) { _joints.Remove(it); } }
/** Adds a joint to the physics world.*/ public virtual void AddJoint(CCPhysicsJoint joint) { if (joint.GetWorld() != null && joint.GetWorld() != this) { joint.RemoveFormWorld(); } AddJointOrDelay(joint); _joints.Add(joint); joint._world = this; }
public virtual void RemoveJointOrDelay(CCPhysicsJoint joint) { var it = _delayAddJoints.Find(j => j == joint); if (it != null) { _delayAddJoints.Remove(it); } if (_info.isLocked()) { if (!_delayAddJoints.Exists(j => j == joint)) { _delayRemoveJoints.Add(joint); _delayDirty = true; } } else { DoRemoveJoint(joint); } }
public virtual void AddJointOrDelay(CCPhysicsJoint joint) { var it = DelayRemoveJoints.Find(j => j == joint); if (it != null) { DelayRemoveJoints.Remove(it); return; } if (Info.IsLocked()) { if (!DelayAddJoints.Exists(j => j == joint)) { DelayAddJoints.Add(joint); DelayDirty = true; } } else { DoAddJoint(joint); } }
/** Remove a joint from physics world.*/ public virtual void RemoveJoint(CCPhysicsJoint joint, bool destroy = true) { if (joint.GetWorld() != this) { if (destroy) { cp.AssertWarn("physics warnning: the joint is not in this world, it won't be destoried utill the body it conntect is destoried"); } return; } RemoveJointOrDelay(joint); _joints.Remove(joint); joint._world = null; // clean the connection to this joint if (destroy) { if (joint.GetBodyA() != null) { joint.GetBodyA().RemoveJoint(joint); } if (joint.GetBodyB() != null) { joint.GetBodyB().RemoveJoint(joint); } // test the distraction is delaied or not if (_delayRemoveJoints.Exists(j => j == joint)) { joint._destoryMark = true; } } }
public void SetCustomString(CCPhysicsJoint item, String propertyName, String val) { m_jointsWithCustomProperties.Add(item); GetCustomPropertiesForItem(item, true).m_customPropertyMap_string.Add(propertyName, val); }
public void SetCustomFloat(CCPhysicsJoint item, String propertyName, float val) { m_jointsWithCustomProperties.Add(item); GetCustomPropertiesForItem(item, true).m_customPropertyMap_float.Add(propertyName, (float)val); }
public String GetJointName(CCPhysicsJoint joint) { if (m_jointToNameMap.ContainsKey(joint)) return m_jointToNameMap[joint]; return null; }
protected void readCustomPropertiesFromJson(CCPhysicsJoint item, JObject value) { if (null == item) return; if (value["customProperties"] != null) return; int i = 0; JArray propValues = (JArray)value["customProperties"]; if (null != propValues) { int numPropValues = propValues.Count; for (i = 0; i < numPropValues; i++) { JObject propValue = (JObject)propValues[i]; String propertyName = propValue["name"].ToString(); if (propValue["int"] != null) SetCustomInt(item, propertyName, (int)propValue["int"]); if (propValue["float"] != null) SetCustomFloat(item, propertyName, (float)propValue["float"]); if (propValue["string"] != null) SetCustomString(item, propertyName, propValue["string"].ToString()); if (propValue["vec2"] != null) SetCustomVector(item, propertyName, this.jsonToVec("vec2", propValue)); if (propValue["bool"] != null) SetCustomBool(item, propertyName, (bool)propValue["bool"]); } } }
protected int lookupJointIndex(CCPhysicsJoint joint) { int? val = m_jointToIndexMap[joint]; if (null != val) return val.Value; else return -1; }
public virtual void AddJointOrDelay(CCPhysicsJoint joint) { var it = _delayRemoveJoints.Find(j => j == joint); if (it != null) { _delayRemoveJoints.Remove(it); return; } if (_info.isLocked()) { if (!_delayAddJoints.Exists(j => j == joint)) { _delayAddJoints.Add(joint); _delayDirty = true; } } else { DoAddJoint(joint); } }
public virtual void DoRemoveJoint(CCPhysicsJoint joint) { _info.removeJoint(joint._info); }
public virtual void DoAddJoint(CCPhysicsJoint joint) { if (joint == null || joint._info == null) { return; } _info.AddJoint(joint._info); }
/** Remove a joint from physics world.*/ public virtual void RemoveJoint(CCPhysicsJoint joint, bool destroy = true) { if (joint.GetWorld() != this) { if (destroy) { cp.AssertWarn("physics warnning: the joint is not in this world, it won't be destoried utill the body it conntect is destoried"); } return; } RemoveJointOrDelay(joint); _joints.Remove(joint); joint._world = null; // clean the connection to this joint if (destroy) { if (joint.GetBodyA() != null) { joint.GetBodyA().RemoveJoint(joint); } if (joint.GetBodyB() != null) { joint.GetBodyB().RemoveJoint(joint); } // test the distraction is delaied or not if (_delayRemoveJoints.Exists(j => j == joint)) { joint._destoryMark = true; } } }
public void RemoveJoint(CCPhysicsJoint joint) { var it = _joints.Find((j) => j == joint); if (it != null) _joints.Remove(it); }
public void SetCustomVector(CCPhysicsJoint item, String propertyName, cpVect val) { m_jointsWithCustomProperties.Add(item); GetCustomPropertiesForItem(item, true).m_customPropertyMap_cpVect.Add(propertyName, val); }
public virtual void RemoveJointOrDelay(CCPhysicsJoint joint) { var it = DelayAddJoints.Find(j => j == joint); if (it != null) { DelayAddJoints.Remove(it); } if (Info.IsLocked()) { if (!DelayAddJoints.Exists(j => j == joint)) { DelayRemoveJoints.Add(joint); DelayDirty = true; } } else { DoRemoveJoint(joint); } }
public virtual void DoRemoveJoint(CCPhysicsJoint joint) { _info.removeJoint(joint._info); }
public void SetJointName(CCPhysicsJoint joint, String name) { m_jointToNameMap.Add(joint, name); }
public virtual void UpdateJoints() { if (_info.isLocked()) { return; } CCPhysicsJoint[] addCopy = new CCPhysicsJoint[_delayAddJoints.Count]; _delayAddJoints.CopyTo(addCopy); _delayAddJoints.Clear(); foreach (var joint in addCopy) { DoAddJoint(joint); } CCPhysicsJoint[] removeCopy = new CCPhysicsJoint[_delayRemoveJoints.Count]; _delayRemoveJoints.CopyTo(removeCopy); _delayRemoveJoints.Clear(); foreach (var joint in removeCopy) { DoRemoveJoint(joint); if (joint._destoryMark) { //delete joint; } } }
public void DrawJoint(CCPhysicsJoint joint) { foreach (cpConstraint item in joint._info.getJoints()) DrawConstraint(item); }
/** Adds a joint to the physics world.*/ public virtual void AddJoint(CCPhysicsJoint joint) { if (joint.GetWorld() != null && joint.GetWorld() != this) { joint.RemoveFormWorld(); } AddJointOrDelay(joint); _joints.Add(joint); joint._world = this; }