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));
     }
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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}");
            }
        }
Beispiel #4
0
 public static object GetSegmentsForNodeId(object msg)
 {
     return(NetUtil.GetSegmentsFromNode((ushort)(uint)msg).Select((seg) => NetLogic.PrepareSegment(seg)).ToList());
 }
Beispiel #5
0
 public static object GetSegmentFromId(object msg)
 {
     return(NetLogic.PrepareSegment((ushort)((uint)msg)));
 }