//For Testing and Visualization Purposes public MainWindow() { InitializeComponent(); WorldInterface.InitializeWorld(WorldSize); var pf = PixelFormats.Bgr24; int rawStride = (WorldSize * pf.BitsPerPixel + 7) / 8; byte[] img = new byte[rawStride * WorldSize]; int p = 0; foreach (var wc in WorldInterface.GetCells()) { var c = CellToBrush(wc.WorldCellType); img[p] = c.B; img[p + 1] = c.G; img[p + 2] = c.R; p += 3; } BitmapSource b = BitmapSource.Create(WorldSize, WorldSize, 96, 96, pf, null, img, rawStride); Image disp = new Image() { Width = 500, Source = b }; drawCanvas.Children.Add(disp); theServer = new Server();; theServer.ClientStatusUpdate += ClientStatus; }
public WorldNetIF(Server s) { Net = s; WorldInterface.AddMoverUpdateCB(MoverUpdated); WorldInterface.AddObjectCreatedCB(ObjectAdded); }
static void Prefix(WorldInterface __instance) { if (Multiplayer.Client == null) { return; } if (Find.World.renderer.wantedMode == WorldRenderMode.Planet) { // Hide trading window for map trades if (Multiplayer.WorldComp.trading.All(t => t.playerNegotiator?.Map != null)) { if (Find.WindowStack.IsOpen(typeof(TradingWindow))) { Find.WindowStack.TryRemove(typeof(TradingWindow), doCloseSound: false); } } // Hide transport loading window if (Find.WindowStack.IsOpen(typeof(TransporterLoadingProxy))) { Find.WindowStack.TryRemove(typeof(TransporterLoadingProxy), doCloseSound: false); } } }
private bool ProcessPlayerAction(StreamWriter s, PacketTypes p, PlayerPerformAction pi) { switch (p) { case PacketTypes.SET: { WorldInterface.PerformAction(pi.id, pi.key, pi.ActionID); return(true); } } return(false); }
// protected GUIText m_guiText; // Use this for initialization void Start() { if (m_initialized) { throw new System.ApplicationException( "Multiple instances of WorldInterfaceWrapper detected."); } m_initialized = true; m_worldIface = WorldInterface.Instance(); }
private bool ProcessPlayerInfo(StreamWriter s, PacketTypes p, PlayerInfo pi) { switch (p) { case PacketTypes.REQUEST: { Player playa = WorldInterface.GetPlayer(pi.id, pi.key); if (playa != null) { PlayerID = pi.id; var coord = playa.GetPosition(); var vel = playa.GetVelocity(); pi = new PlayerInfo(PacketTypes.REQUESTED) { id = playa.Id, x = coord.x, y = coord.y, vx = vel.x, vy = vel.y }; s(NetHelpers.ConvertStructToBytes(pi)); //Send over object positions in the region surrounding our player //DON'T DO THIS YET... Still thinking about it, Client needs to support it foreach (var obj in WorldInterface.GetRegionObjects(coord.x - 10, coord.x + 10, coord.y - 10, coord.y + 10)) { if (obj == null) { continue; } var oc = obj.GetPosition(); var oi = new ObjectInfo(PacketTypes.REQUESTED) { id = obj.Id, objecttype = (int)obj.ObjectType, x = oc.x, y = oc.y, vx = 0, vy = 0, }; s(NetHelpers.ConvertStructToBytes(oi)); } } return(true); } } return(false); }
private bool ProcessPlayerControl(StreamWriter s, PacketTypes p, PlayerControl pi) { switch (p) { case PacketTypes.SET: { Player playa = WorldInterface.GetPlayer(pi.id, pi.key); if (playa != null) { playa.SetDirection(pi.direction, pi.paces); } return(true); } } return(false); }
protected virtual void Init() { canvas = Canvas.FindObjectOfType<Canvas>(); canvasManager = canvas.GetComponent<CanvasManager>(); //WorldInterface.CreateGameWorld(worldSize); worldInterface = WorldInterface.CreateWorldInterface(worldSize); pointObjectManager = PointObjectManager.CreatePointObjectManager(); actionManager = gameObject.AddComponent<ActionManager>(); workManager = gameObject.AddComponent<WorkManager>(); pathFinder = new Pathfinder(); if (buildStartArea) { BuildStartArea(); } }
public void ConstructComponents() { worldObjects = new WorldObjectsHolder(); factionManager = new FactionManager(); worldPawns = new WorldPawns(); gameConditionManager = new GameConditionManager(this); storyState = new StoryState(this); renderer = new WorldRenderer(); UI = new WorldInterface(); debugDrawer = new WorldDebugDrawer(); dynamicDrawManager = new WorldDynamicDrawManager(); pathFinder = new WorldPathFinder(); pathPool = new WorldPathPool(); reachability = new WorldReachability(); floodFiller = new WorldFloodFiller(); ticksAbsCache = new ConfiguredTicksAbsAtGameStartCache(); components.Clear(); FillComponents(); }
public virtual void Awake() { LoadFromXML(); worldInterface = GameManager.worldInterface; if (worldInterface == null) { DebugOutput.Shout("KABLAM# worldinterface is null"); } worldInterface.RegisterOnChangedPoint(OnChangedPoints); worldTree = new IndexingWorldTree((sbyte)GameManager.worldSize); worldTree.Init(); if (popPrefabs == null) { DebugOutput.Shout("La merde! popPrefabs is null!"); } pendingChangedPoints = new List<ChangedPoint>(); }
public void ConstructComponents() { this.worldObjects = new WorldObjectsHolder(); this.factionManager = new FactionManager(); this.uniqueIDsManager = new UniqueIDsManager(); this.worldPawns = new WorldPawns(); this.settings = new WorldSettings(); this.gameConditionManager = new GameConditionManager(null); this.storyState = new StoryState(this); this.renderer = new WorldRenderer(); this.UI = new WorldInterface(); this.debugDrawer = new WorldDebugDrawer(); this.dynamicDrawManager = new WorldDynamicDrawManager(); this.pathFinder = new WorldPathFinder(); this.pathPool = new WorldPathPool(); this.reachability = new WorldReachability(); this.floodFiller = new WorldFloodFiller(); this.ticksAbsCache = new ConfiguredTicksAbsAtGameStartCache(); this.components.Clear(); this.FillComponents(); }
private void CreateMaker() { int x = 0, y = 0; switch (Heading) { case 0: y = (int)Y - 1; x = (int)X; break; case 1: x = (int)X + 1; y = (int)Y; break; case 2: y = (int)Y + 1; x = (int)X; break; case 3: x = (int)X - 1; y = (int)Y; break; } if (x >= 0 && x < WorldInterface.WORLD_SIZE && y >= 0 && y < WorldInterface.WORLD_SIZE) { if (WorldInterface.IsObjectNull(x, y)) { KolonyMarker k = new KolonyMarker(x, y, ""); k.SetOwner(Id); WorldInterface.AddObject(k); } } }
public override void Execute(WorldInterface @on) { throw new System.NotImplementedException(); }
private bool ProcessRegionInfo(StreamWriter s, PacketTypes p, RegionInfo ri) { switch (p) { case PacketTypes.REQUEST: { //Get Cell Type Info if ((ri.regionDataTypes & WorldConstants.REGION_INFO_CELL) != 0) { CellInfo c = new CellInfo(PacketTypes.REQUESTED); List <WorldCell> region = new List <WorldCell>(WorldInterface.GetRegionCells(ri.x1, ri.x2, ri.y1, ri.y2)); int count = region.Count; foreach (WorldCell wc in region) { c.cellType = (byte)wc.WorldCellType; c.remainingCells = --count; // I don't even know if this is necessary anymore... c.x = wc.X; c.y = wc.Y; s(NetHelpers.ConvertStructToBytes(c)); } } //Get Object Info if ((ri.regionDataTypes & WorldConstants.REGION_INFO_OBJECT) != 0 || (ri.regionDataTypes & WorldConstants.REGION_INFO_PLAYER) != 0) { bool obj = (ri.regionDataTypes & WorldConstants.REGION_INFO_OBJECT) != 0; bool ply = (ri.regionDataTypes & WorldConstants.REGION_INFO_PLAYER) != 0; ObjectInfo o = new ObjectInfo(PacketTypes.REQUESTED); foreach (var wobject in WorldInterface.GetRegionObjects(ri.x1, ri.x2, ri.y1, ri.y2)) { if (wobject == null) { continue; } var pos = wobject.GetPosition(); if (wobject.ObjectType == WorldObjectTypes.PLAYER && ply) { var vel = ((Player)wobject).GetVelocity(); o.id = wobject.Id; o.x = pos.x; o.y = pos.y; o.vx = vel.x; o.vy = vel.y; o.objecttype = WorldConstants.TYPE_PLAYER; s(NetHelpers.ConvertStructToBytes(o)); } else if (obj) { o.id = wobject.Id; o.x = pos.x; o.y = pos.y; if (wobject.ObjectType == WorldObjectTypes.MARKER) { o.objecttype = WorldConstants.TYPE_MARKER; } else if (wobject.ObjectType == WorldObjectTypes.MOVEABLE) { var vel = ((Moveable)wobject).GetVelocity(); o.objecttype = WorldConstants.TYPE_MOVEABLE; o.vx = vel.x; o.vy = vel.y; } else { o.objecttype = WorldConstants.TYPE_GENERIC; } s(NetHelpers.ConvertStructToBytes(o)); } } } return(true); } } return(false); }
/* static public void CreateGameWorld(int wSize) { worldInterface.Init(wSize); }*/ public static WorldInterface CreateWorldInterface(int wSize) { if (_worldInterface == null) { GameObject g = GameObject.Find("_worldInterface"); if (g == null) { g = new GameObject("_worldInterface"); } _worldInterface = g.AddComponent<WorldInterface>(); _worldInterface.Init(wSize); } return _worldInterface; }
// Use this for initialization void Start() { m_worldIface = WorldInterface.Instance(); // This is a singleton m_id = this.GetComponent <WorldObject>().m_id; }
void Update() { // capture cursor if (Screen.lockCursor != lockCursor) { if (lockCursor && Input.GetMouseButton(0)) { Screen.lockCursor = true; } else if (!lockCursor) { Screen.lockCursor = false; } } // interact with the world Ray ray = new Ray(cameraObject.transform.position, cameraObject.transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, reach)) { // did hit targetCube.transform.position = WorldInterface.GetHitPositionIn(hit); targetCube.SetActive(true); ushort block = WorldInterface.GetBlock(world, hit); blockIndicator.text = Block.GetInstance(block).name; if (InputProxy.GetButtonDown("Dig")) { if (!Block.GetInstance(block).indestructable) { WorldInterface.ReplaceBlock(world, hit, Block.AIR); GetComponent <CollideWithTerrain>().collisionMaker.UpdateColliders(); } } if (InputProxy.GetButtonDown("Use")) { WorldInterface.AddBlock(world, hit, held); GetComponent <CollideWithTerrain>().collisionMaker.UpdateColliders(); } if (InputProxy.GetButtonDown("Equip")) { held = WorldInterface.GetBlock(world, hit); } } else { // did not hit blockIndicator.text = ""; targetCube.SetActive(false); } // set fog based on camera position ushort headBlock = WorldInterface.GetBlock(world, Camera.main.transform.position); fog.water = false; foreach (ushort water in Block.WATER) { if (headBlock == water) { fog.water = true; break; } } }