aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/world/Entity.cs
blob: 7880a4675b69357f3c6a6e49ff2e49775042fa26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Collections.Generic;
using System.Text;
using Axiom.MathLib;
using libsecondlife;
using OpenSim.types;
using libsecondlife.Packets;

namespace OpenSim.world
{
    public class Entity
    {
        protected libsecondlife.LLUUID uuid;
	protected uint localid;
	public LLVector3 position;
	public LLVector3 velocity;
        protected Quaternion rotation;
        protected string name;
        protected List<Entity> children;
	public bool needupdate;

        public Entity()
        {
            uuid = new libsecondlife.LLUUID();
	    localid = 8880000 + (OpenSim_Main.local_world._localNumber++); // FIXME - race condition!
            position = new LLVector3();
            velocity = new LLVector3();
            rotation = new Quaternion();
            name = "(basic entity)";
            children = new List<Entity>();
        }

        public virtual void update() {
            // Do any per-frame updates needed that are applicable to every type of entity
            foreach (Entity child in children)
            {
            	if(child.needupdate) 
			child.update();
            }
	    this.needupdate=false;
        }

	public virtual ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() {
		return null;
	}


        public virtual string getName()
        {
            return name;
        }

        public virtual Mesh getMesh()
        {
            Mesh mesh = new Mesh();

            foreach (Entity child in children)
            {
                mesh += child.getMesh();
            }

            return mesh;
        }
    }
}