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 CreateTree(object msg) { var data = (CreateTreeMessage)msg; TreeInfo info = PrefabCollection <TreeInfo> .FindLoaded(data.prefab_name); Util.Assert(info, "Prefab '" + data.prefab_name + "' not found"); uint id = ManagersUtil.CreateTree(data.Position.ToUnityTerrain(), info, true); return(ManagersLogic.PrepareTree(id)); }
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 GetTreeFromId(object msg) { return(ManagersLogic.PrepareTree((uint)((uint)msg))); }