public static Ship CreateShipAtCommNode(Core instance, User user, CommunicationNode node) { var TargetRegionId = GeometryIndex.calcRegionId(node.positionX, node.positionY); Field Field = GeometryIndex.regions[TargetRegionId].findOrCreateField(node.positionX, node.positionY); return(CreateShipAtField(instance, user, Field)); }
public static Field mockField() { int targetRegionId = GeometryIndex.calcRegionId(5001, 5001); Field field = GeometryIndex.regions[targetRegionId].findOrCreateField(5001, 5001); return(field); }
public void getCommNodeMessageTest() { instance.commNodes.First().Value.commNodeMessages.Clear(); instance.identities.commNodeMessage.id = 0; //create user User user = Mock.mockGeneratedUser(instance); List <SpacegameServer.BC.XMLGroups.CommNode> commNodes = SpacegameServer.BC.XMLGroups.CommNodes.createKnownAndNearNodesList(user); var node = commNodes.First().node; //create ship SpacegameServer.Core.ShipBuild builder = new ShipBuild(instance); int newShipId = (int)instance.identities.shipLock.getNext(); ShipTemplate template = instance.shipTemplate.Where(e => e.Value.hullid == 1).First().Value; var targetRegionId = GeometryIndex.calcRegionId(node.positionX, node.positionY); Field field = GeometryIndex.regions[targetRegionId].findOrCreateField(node.positionX, node.positionY); Colony colony = Mock.mockColony(ColonyUserId: user.id); Ship newShip = builder.buildShip(newShipId, template, field, user.id, colony, false); //add user to commNode node.checkAndAddUser(user, newShip); node.sendCommMessage(user, "head1", "body1"); node.sendCommMessage(user, "head2", "body2"); SpacegameServer.BC.BusinessConnector bc = new SpacegameServer.BC.BusinessConnector(); string ret = bc.getCommNodeMessage(user.id, node.id, 0, 50); string expected = @"<messages> <message> <id>2</id> <commNodeId>" + node.id.ToString() + @"</commNodeId> <sender>" + user.id.ToString() + @"</sender> <headline>head2</headline> <messageBody>body2</messageBody> <sendingDate>2015-07-08T20:48:43.2544728Z</sendingDate> <newMessage>0</newMessage> </message> <message> <id>1</id> <commNodeId>" + node.id.ToString() + @"</commNodeId> <sender>1</sender> <headline>head1</headline> <messageBody>body1</messageBody> <sendingDate>2015-07-08T20:48:43.2464723Z</sendingDate> <newMessage>0</newMessage> </message> </messages>"; //sendingDate can't be tested, since it is set to Now() // so only the first few lines are compared ret = String.Join("", ret.Split(new[] { '\r', '\n' }).Where((e, i) => i < 14)); expected = String.Join("", expected.Split(new[] { '\r', '\n' }).Where((e, i) => i < 14)); Assert.AreEqual(expected, ret); }
public string GetFullNameString(string defval) { string name = GetNameString(defval); if (Geometry != null) { name += " (" + GeometryIndex.ToString() + ")"; } return(name); }
private Ship createShipAtCommNode(User user, CommunicationNode node) { SpacegameServer.Core.ShipBuild builder = new ShipBuild(instance); int newShipId = (int)instance.identities.shipLock.getNext(); ShipTemplate template = instance.shipTemplate.Where(e => e.Value.hullid == 1).First().Value; var targetRegionId = GeometryIndex.calcRegionId(node.positionX, node.positionY); Field field = GeometryIndex.regions[targetRegionId].findOrCreateField(node.positionX, node.positionY); Colony colony = Mock.mockColony(ColonyUserId: user.id); Ship newShip = builder.buildShip(newShipId, template, field, user.id, colony, false); return(newShip); }
public string GetFullNameString(string defval) { string name = defval; if (MultipleSelection) { name = "Multiple items"; } else if (EntityDef != null) { name = EntityDef._CEntityDef.archetypeName.ToString(); } else if (Archetype != null) { name = Archetype.Hash.ToString(); } else if (CollisionBounds != null) { name = CollisionBounds.GetName(); } if (Geometry != null) { name += " (" + GeometryIndex.ToString() + ")"; } if (TimeCycleModifier != null) { name = TimeCycleModifier.CTimeCycleModifier.name.ToString(); } if (BoxOccluder != null) { name = "BoxOccluder " + (BoxOccluder.Ymap?.Name ?? "") + ": " + BoxOccluder.Index.ToString(); } if (OccludeModel != null) { name = "OccludeModel " + (OccludeModel.Ymap?.Name ?? "") + ": " + OccludeModel.Index.ToString(); } if (CarGenerator != null) { name = CarGenerator.NameString(); } if (EntityExtension != null) { name += ": " + EntityExtension.Name; } if (ArchetypeExtension != null) { name += ": " + ArchetypeExtension.Name; } if (WaterQuad != null) { name = "WaterQuad " + WaterQuad.ToString(); } if (NavPoly != null) { name = "NavPoly " + NavPoly.ToString(); } if (NavPoint != null) { name = "NavPoint " + NavPoint.ToString(); } if (NavPortal != null) { name = "NavPortal " + NavPortal.ToString(); } if (PathNode != null) { name = "PathNode " + PathNode.AreaID.ToString() + "." + PathNode.NodeID.ToString();// + FloatUtil.GetVector3String(PathNode.Position); } if (TrainTrackNode != null) { name = "TrainTrackNode " + FloatUtil.GetVector3String(TrainTrackNode.Position); } if (ScenarioNode != null) { name = ScenarioNode.ToString(); } if (Audio != null) { name = Audio.ShortTypeName + " " + Audio.GetNameString();// + FloatUtil.GetVector3String(Audio.InnerPos); } if (MloRoomDef != null) { name = "MloRoomDef " + MloRoomDef.RoomName; } return(name); }