public object ToMessage() { if (ObjectType == Type.Point) { return(_point.position.FromUnity()); } else if (ObjectType == Type.Node) { return(NetLogic.PrepareNode((ushort)Id)); } else if (ObjectType == Type.Segment) { return(NetLogic.PrepareSegment((ushort)Id)); } else if (ObjectType == Type.Building) { return(ManagersLogic.PrepareBuilding((ushort)Id)); } else if (ObjectType == Type.Prop) { return(ManagersLogic.PrepareProp((ushort)Id)); } else { return(ManagersLogic.PrepareTree(Id)); } }
private static object GetObjectFromIdInternal(uint id, string idString, string type) { object ret; switch (type) { case "node": ret = NetLogic.PrepareNode((ushort)(id)); break; case "segment": ret = NetLogic.PrepareSegment((ushort)(id)); break; case "building": ret = ManagersLogic.PrepareBuilding((ushort)(id)); break; case "prop": ret = ManagersLogic.PrepareProp((ushort)(id)); break; case "tree": ret = ManagersLogic.PrepareTree((uint)(id)); break; case "net prefab": ret = NetLogic.PrepareNetInfo(idString); break; default: throw new Exception($"Unknown type '{type}'"); } return(ret); }
public static object CreateProp(object msg) { var data = (CreatePropMessage)msg; PropInfo info = PrefabCollection <PropInfo> .FindLoaded(data.Type); Util.Assert(info, "Prefab '" + data.Type + "' not found"); return(ManagersLogic.PrepareProp(ManagersUtil.CreateProp(data.Position.ToUnityTerrain(), (float)data.Angle, info, true))); }
public static InstanceData Move(MoveMessage msg) { switch (msg.type) { case "node": MoveableNode mnode = new MoveableNode(new InstanceID() { NetNode = (ushort)msg.id }); mnode.MoveCall(msg.position != null ? msg.position.ToUnity() : mnode.position); return(NetLogic.PrepareNode((ushort)msg.id)); case "segment": MoveableSegment seg = new MoveableSegment(new InstanceID() { NetSegment = (ushort)msg.id }); seg.MoveCall(msg.position != null ? msg.position.ToUnity() : seg.position); return(NetLogic.PrepareSegment((ushort)msg.id)); case "building": MoveableBuilding b = new MoveableBuilding(new InstanceID() { Building = (ushort)msg.id }); b.MoveCall(msg.position != null ? msg.position.ToUnity() : b.position, msg.is_angle_defined ? msg.angle : b.angle); return(ManagersLogic.PrepareBuilding((ushort)msg.id)); case "prop": MoveableProp p = new MoveableProp(new InstanceID() { Prop = (ushort)msg.id }); p.MoveCall(msg.position != null ? msg.position.ToUnity() : p.position, msg.is_angle_defined ? msg.angle : p.angle); return(ManagersLogic.PrepareProp((ushort)msg.id)); case "tree": MoveableTree t = new MoveableTree(new InstanceID() { Tree = msg.id }); t.MoveCall(msg.position != null ? msg.position.ToUnity() : t.position); return(ManagersLogic.PrepareTree(msg.id)); default: throw new Exception($"Cannot move {msg.type}"); } }
public static object GetPropFromId(object msg) { return(ManagersLogic.PrepareProp((ushort)((uint)msg))); }