public HullNode getRightMost(HullNode first) { HullNode currentNode = first; // Setting up for the loop HullNode currentRightMost = first; // All else fails, the first is the leftmost // Go through the entire hull to find the node with the leftmost point do { if (currentNode.point.X > currentRightMost.point.X) { currentRightMost = currentNode; } currentNode = currentNode.next; } while (currentNode != first); return(currentRightMost); }
public void SaveEquipment(NodeAddedEvent e, [Combine] RoundUserNode user, [Context, JoinByUser] HullNode hull, [Context, JoinByUser] TurretNode turret) { if (user.Entity.HasComponent <RoundUserEquipmentComponent>()) { RoundUserEquipmentComponent component = user.Entity.GetComponent <RoundUserEquipmentComponent>(); component.HullId = hull.marketItemGroup.Key; component.WeaponId = turret.marketItemGroup.Key; } else { RoundUserEquipmentComponent component = new RoundUserEquipmentComponent { HullId = hull.marketItemGroup.Key, WeaponId = turret.marketItemGroup.Key }; user.Entity.AddComponent(component); } }
// All of my code is the following public void Solve(List <System.Drawing.PointF> pointList) { // Solve the hull problem // Gotta have a sorted list! List <System.Drawing.PointF> sortedList = pointList.OrderBy(o => o.X).ToList(); HullNode solvedHull = getHull(sortedList); // Print it to the screen Pen greenPen = new Pen(Color.Green); HullNode currentNode = solvedHull; do { g.DrawLine(greenPen, currentNode.point, currentNode.next.point); currentNode = currentNode.next; // This might not draw the last line. but it should almost draw everything. } while (currentNode != solvedHull); // When we get all the way around, stop }
public void InitHull(NodeAddedEvent e, SingleNode <CustomizationUIComponent> ui, HullNode hull, [Context, JoinByMarketItem] MarketItemNode marketItem) { ui.component.Hull = GarageItemsRegistry.GetItem <TankPartItem>(marketItem.Entity); }
public void SetHulls(NodeAddedEvent e, [Combine] HullIndicatorNode hullIndicator, [Context, JoinByUser] HullNode hull) { this.SetHull(hullIndicator, hull); }
private void SetHull(HullIndicatorNode hullIndicator, HullNode hull) { hullIndicator.scoreTableHullIndicator.SetHullIcon(hull.marketItemGroup.Key); }
public void UpdateTracer(UpdateWeaponStreamTracerByTargetTankEvent evt, HullNode tank) { GameObject hullInstance = tank.hullInstance.HullInstance; Vector3 position = MathUtil.LocalPositionToWorldPosition(evt.Hit.LocalHitPoint, hullInstance); evt.WeaponStreamTracerBehaviour.TargetPosition = MathUtil.WorldPositionToLocalPosition(position, evt.WeaponStreamTracerInstance); }
private void SetCaseVelocity(GameObject cartridgeCase, CartridgeCaseEjectorComponent component, HullNode hullNode) { GameObject hullInstance = hullNode.hullInstance.HullInstance; Rigidbody rigidbody = hullNode.rigidbody.Rigidbody; Rigidbody rigidbody2 = cartridgeCase.GetComponent <Rigidbody>(); Vector3 rhs = cartridgeCase.transform.position - hullInstance.transform.position; rigidbody2.SetVelocitySafe((component.transform.TransformDirection((Vector3)(component.initialSpeed * Vector3.forward)) + rigidbody.velocity) + Vector3.Cross(rigidbody.angularVelocity, rhs)); rigidbody2.SetAngularVelocitySafe(component.transform.TransformDirection((Vector3)(component.initialAngularSpeed * Vector3.up)) + rigidbody.angularVelocity); }
public void EjectCase(CartridgeCaseEjectionEvent e, SingleNode <CartridgeCaseEjectorComponent> ejectorNode, [JoinByTank] HullNode hullNode, [JoinAll] SingleNode <CartridgeCaseContainerComponent> containerNode) { if (hullNode.Entity.HasComponent <SelfTankComponent>() || hullNode.cameraVisibleTrigger.IsVisibleAtRange(30f)) { GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent { Prefab = ejectorNode.component.casePrefab }; base.ScheduleEvent(eventInstance, ejectorNode); GameObject gameObject = eventInstance.Instance.gameObject; this.SetCaseTransform(gameObject, ejectorNode.component); this.SetCaseVelocity(gameObject, ejectorNode.component, hullNode); gameObject.SetActive(true); } }
public void UpdateHitEffect(UpdateWeaponStreamHitGraphicsByTargetTankEvent evt, HullNode tank) { Vector3 vector = tank.hullInstance.HullInstance.transform.TransformPoint(evt.TankHit.LocalHitPoint); Quaternion quaternion = Quaternion.LookRotation(evt.TankHit.HitDirection); evt.HitTargetParticleSystem.transform.position = vector - (evt.TankHit.HitDirection * evt.HitOffset); evt.HitTargetParticleSystem.transform.rotation = quaternion; evt.HitTargetParticleSystem.Play(true); evt.HitTargetLight.enabled = true; }
public void InitHullForBattleSelectScreen(NodeAddedEvent e, SingleNode <MatchLobbyGUIComponent> ui, HullNode hull, [Context, JoinByMarketItem] MarketItemNode marketItem) { ui.component.Hull = GarageItemsRegistry.GetItem <TankPartItem>(marketItem.Entity); ui.component.SetHullLabels(); }
// The real meat of the algorithm is in here. >:) public HullNode mergeHulls(HullNode L, HullNode R) { HullNode currentNode = L; do { //g.DrawLine(greenPen, currentNode.point, currentNode.next.point); currentNode = currentNode.next; // This might not draw the last line. but it should almost draw everything. } while (currentNode != L); // When we get all the way around, stop currentNode = R; do { //g.DrawLine(greenPen, currentNode.point, currentNode.next.point); currentNode = currentNode.next; // This might not draw the last line. but it should almost draw everything. } while (currentNode != R); // When we get all the way around, stop // Merge the top HullNode l_top = getRightMost(L); // Get the rightmost point of L HullNode r_top = getLeftMost(R); // And the leftmost point of R while (true) { // Going counterclockwise on L, make new lines to the new points from the right HullNode l_counterclockwise = l_top; HullNode l_next; double currentSlope = (r_top.point.Y - l_counterclockwise.point.Y) / (r_top.point.X - l_counterclockwise.point.X); // Rise over run double nextSlope; while (true) // While slope gets more negative { l_next = l_counterclockwise.previous; // Going even more counterclockwise nextSlope = (r_top.point.Y - l_next.point.Y) / (r_top.point.X - l_next.point.X); if (nextSlope >= currentSlope) // Oh no! We have gone too far! { break; } // nextSlope is more negative. We are going in the right direction. currentSlope = nextSlope; l_counterclockwise = l_next; } // When we break out of the loop here, we have found the most negative slope for the given r. // Time to find the most positive slope for our found l. // Going clockwise on R, make new lines to the found l. HullNode r_clockwise = r_top; HullNode r_next; while (true) { r_next = r_clockwise.next; // Going clockwise nextSlope = (r_next.point.Y - l_counterclockwise.point.Y) / (r_next.point.X - l_counterclockwise.point.X); // Rise over run if (nextSlope <= currentSlope) // Oh no! We have gone too far! { break; } // Nextslope is more positive. We are going in the right direction currentSlope = nextSlope; r_clockwise = r_next; } // If neither r nor l have changed, we have found the very top line. if (r_clockwise == r_top && l_counterclockwise == l_top) { break; // We have found the top and r_top and l_top are the correct nodes } r_top = r_clockwise; // Reset the variables to iterate again l_top = l_counterclockwise; // Reset the variables to iterate again. } // Merge the bottom HullNode l_bottom = getRightMost(L); // Get the rightmost point of L HullNode r_bottom = getLeftMost(R); // And the leftmost point of R while (true) { // Going clockwise on L, draw new lines to the set point on R HullNode l_clockwise = l_bottom; HullNode l_next; double currentSlope = (r_bottom.point.Y - l_clockwise.point.Y) / (r_bottom.point.X - l_clockwise.point.X); // Rise over run double nextSlope; while (true) // While the slope gets even more POSITIVE { l_next = l_clockwise.next; // Going clockwise nextSlope = (r_bottom.point.Y - l_next.point.Y) / (r_bottom.point.X - l_next.point.X); if (nextSlope <= currentSlope) // We are trying to get positive! This is too far! { break; } // nextSlope is more positive. We are going in the right direction currentSlope = nextSlope; l_clockwise = l_next; } // When we break out of the above loop, we have found the most POSITIVE slope for the given r. // Time to find the most NEGATIVE slope for our found l. // Going COUNTERCLOCKWISE on R, draw new lines to our found l. HullNode r_counterclockwise = r_bottom; HullNode r_next; while (true) { r_next = r_counterclockwise.previous; // Going COUNTERCLOCKWISE nextSlope = (r_next.point.Y - l_clockwise.point.Y) / (r_next.point.X - l_clockwise.point.X); // Rise over run if (nextSlope >= currentSlope) // Oh no! We gound a greater slope! we want negative! { break; } //Next slope is more negative. We are going in the right direction currentSlope = nextSlope; r_counterclockwise = r_next; } // If neither r nor l have changed, we have found the very top line. if (r_counterclockwise == r_bottom && l_clockwise == l_bottom) { break; // We have found the top and r_top and l_top are the correct nodes } r_bottom = r_counterclockwise; // Reset the variables to iterate again l_bottom = l_clockwise; // Reset the variables to iterate again. } // When the above two sections have finished, we should have // r_bottom, l_bottom // r_top, l_top // They need to be connected together, and all nodes between them need to be eliminated. // Merge the lists together // It is as simple as changing the next and previous pointers to point to the correct nodes. r_bottom.next = l_bottom; l_bottom.previous = r_bottom; l_top.next = r_top; r_top.previous = l_top; // To return, just return one of the nodes. They all point to each other. return(r_top); }
// When we make a new node, it is its own list- it has a point, and the next in the list is itself public HullNode(System.Drawing.PointF point) { this.point = point; this.next = this; this.previous = this; }
public void ShowUpgradeLevelRestrictionDescription(ListItemSelectedEvent e, UpgradeLevelRestrictionGraffitiNode upgradeLevelRestriction, [JoinByMarketItem] SingleNode <MountUpgradeLevelRestrictionComponent> marketItem, [JoinByParentGroup] HullNode hull, [JoinAll] ScreenNode screen) { screen.garageItemsScreen.UpgradeLevelRestrictionDescription.Description = screen.garageItemsScreenText.HullUpgradeLevelRestrictionDescription.Replace(ITEM_upgLEVEL, marketItem.component.RestrictionValue.ToString()).Replace(ITEM_NAME, hull.descriptionItem.Name); screen.garageItemsScreen.UpgradeLevelRestrictionDescription.gameObject.SetActive(true); }