From 09dd4bd6834861791008e66652826a66724efa0e Mon Sep 17 00:00:00 2001 From: gareth Date: Tue, 27 Feb 2007 23:00:49 +0000 Subject: Brought in code from branches/gareth --- src/world/World.cs | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/world/World.cs (limited to 'src/world/World.cs') diff --git a/src/world/World.cs b/src/world/World.cs new file mode 100644 index 0000000..cf337a8 --- /dev/null +++ b/src/world/World.cs @@ -0,0 +1,57 @@ +using System; +using libsecondlife; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.world +{ + public class World + { + public Dictionary Entities; + public SurfacePatch[] LandMap; + public ScriptEngine Scripts; + + public World() + { + Console.WriteLine("World.cs - creating new entitities instance"); + Entities = new Dictionary(); + + // We need a 16x16 array of 16m2 surface patches for a 256m2 sim + Console.WriteLine("World.cs - creating LandMap"); + LandMap = new SurfacePatch[16*16]; + int xinc; + int yinc; + for(xinc=0; xinc<16; xinc++) for(yinc=0; yinc<16; yinc++) { + LandMap[xinc+(yinc*16)]=new SurfacePatch(); + } + + Console.WriteLine("World.cs - Creating script engine instance"); + // Initialise this only after the world has loaded + Scripts = new ScriptEngine(this); + } + + public void Update() + { + foreach (libsecondlife.LLUUID UUID in Entities.Keys) + { + Entities[UUID].update(); + } + } + + public void AddViewerAgent(OpenSimClient AgentClient) { + Console.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); + Avatar NewAvatar = new Avatar(AgentClient); + Console.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); + this.Entities.Add(AgentClient.AgentID, NewAvatar); + Console.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); + NewAvatar.SendRegionHandshake(this); + this.Update(); // will work for now, but needs to be optimised so we don't update everything in the sim for each new user + } + + public bool Backup() { + /* TODO: Save the current world entities state. */ + + return false; + } + } +} -- cgit v1.1