public override IEnumerable<Barebones.Dependencies.IDependency> GetDependencies() { yield return new Dependency<PhysicsComponent>(item => m_Physics = item); yield return new Dependency<Recrutable>(item => m_Recrutable = item); yield return new Dependency<JointComponent>(item => m_Joint = item); yield return new Dependency<GameplayManager>(item => m_GM = item); }
private void HandleComponentState(EntityUid uid, JointComponent component, ref ComponentHandleState args) { if (args.Current is not JointComponent.JointComponentState jointState) { return; } var changed = new List <string>(); foreach (var(existing, _) in component.Joints) { if (!jointState.Joints.ContainsKey(existing)) { changed.Add(existing); } } foreach (var removed in changed) { RemoveJoint(component.Joints[removed]); } foreach (var(id, state) in jointState.Joints) { Joint joint; if (!component.Joints.ContainsKey(id)) { // Add new joint (if possible). // Need to wait for BOTH joint components to come in first before we can add it. Yay dependencies! if (!EntityManager.HasComponent <JointComponent>(state.UidA) || !EntityManager.HasComponent <JointComponent>(state.UidB)) { continue; } joint = state.GetJoint(); AddJoint(joint); continue; } joint = state.GetJoint(); var existing = component.Joints[id]; if (!existing.Equals(joint)) { existing.ApplyState(state); component.Dirty(); } } if (changed.Count > 0) { component.Dirty(); } }
public float Component(string name, JointComponent jc) { if (jc == JointState.JointComponent.Angle) { return(Angle(name)); } else { return(Pos(name).Comp((int)jc)); } }
private void GetCompState(EntityUid uid, JointComponent component, ref ComponentGetState args) { var states = new Dictionary<string, JointState>(component.Joints.Count); foreach (var (_, joint) in component.Joints) { states.Add(joint.ID, joint.GetState()); } args.State = new JointComponent.JointComponentState(states); }
public float Component(string name, JointComponent jc) { if ( jc == JointState.JointComponent.Angle ) { return Angle(name); } else { return Pos(name).Comp((int)jc); } }