public bool InRange(SimElement inRangeOf, int range, float angle) { if (Vector2.Distance(position, inRangeOf.position) <= range && Vector2.Angle(position - inRangeOf.position, inRangeOf.orientation) <= angle / 2 && Vector2.Angle(position - inRangeOf.position, inRangeOf.orientation) >= -angle / 2 && !this == inRangeOf) { return(true); } return(false); }
public static List <SimElement> GetInRange(SimElement inRangeOf) { List <SimElement> inRange = new List <SimElement>(); foreach (var item in elements) { if (item.InRange(inRangeOf, Creature.CREATURERANGE, Creature.CREATUREFOA)) { inRange.Add(item); } } return(inRange); }
public static SortedList <float, SimElement> GetInRange(SimElement inRangeOf, int range, float angle) { SortedList <float, SimElement> inRange = new SortedList <float, SimElement>(); foreach (var item in elements) { if (item.InRange(inRangeOf, range, angle)) { inRange.Add(Vector2.Distance(inRangeOf.position, item.position), item); } } return(inRange); }
/* * Marker manage */ SimElemMarker MakeMarker(string id, SimElement simElem, Vector3 pos) { var marker = GetObject(id, pos); marker.elemType = id; marker.uid = simElem.uid; List <SimElemMarker> markers; if (!_markerDic.TryGetValue(id, out markers)) { markers = new List <SimElemMarker>(); _markerDic.Add(id, markers); } markers.Add(marker); return(marker); }
void DeleteMarker(string id, SimElement simElem) { List <SimElemMarker> markers; if (!_markerDic.TryGetValue(id, out markers)) { return; } for (var i = 0; i < markers.Count; ++i) { if (markers[i].uid == simElem.uid) { markers[i].gameObject.SetActive(false); markers.RemoveAt(i); return; } } }
internal override void createProduct(SimObjectBase instance, BEPUikScene scene) { BEPUikBone connectionA = null; BEPUikBone connectionB = null; SimObject other = instance.getOtherSimObject(ConnectionASimObjectName); if (other == null) { throw new BEPUikBlacklistException("Cannot find ConnectionA SimObject named '{0}'", ConnectionASimObjectName); } connectionA = other.getElement(ConnectionABoneName) as BEPUikBone; if (connectionA == null) { throw new BEPUikBlacklistException("Cannot find ConnectionA bone named '{0}' in '{1}'", ConnectionABoneName, ConnectionASimObjectName); } other = instance.getOtherSimObject(ConnectionBSimObjectName); if (other == null) { throw new BEPUikBlacklistException("Cannot find ConnectionB SimObject named '{0}'", ConnectionBSimObjectName); } connectionB = other.getElement(ConnectionBBoneName) as BEPUikBone; if (connectionB == null) { throw new BEPUikBlacklistException("Cannot find ConnectionB bone named '{0}' in '{1}'", ConnectionBBoneName, ConnectionBSimObjectName); } SimElement element = createConstraint(connectionA, connectionB, instance); if (element != null) { instance.addElement(element); } }
public float GetAngle(SimElement other) { var l = new Vector2(other.position.x - position.x, other.position.y - position.y); return(Vector2.Angle(orientation, l)); }
public float GetDistance(SimElement other) { return(Vector2.Distance(position, other.position)); }
public static void Add(SimElement item) { elements.Add(item); }
public static string GetFQName(this SimElement element) => element.Unit.IsAString() ? $"{element.Name} [{element.Unit}]" : element.Name;
public void AddSimElement(SimElement simElement, int order = 0) { orderedSimElements.Add(new OrderedSimElement(order, simElement)); }
public OrderedSimElement(int order, SimElement simElement) { this.order = order; this.simElement = simElement; }