aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
authorTeravus Ovares2008-05-03 15:39:40 +0000
committerTeravus Ovares2008-05-03 15:39:40 +0000
commite8acb49fefc0e567510b4058b6571599a0158b62 (patch)
treed87243f8d596b6df07db190ba30bf2da4d608c18 /OpenSim/Region/Environment/Scenes/ScenePresence.cs
parent* Committing some collision stuffs that I'm working on. (diff)
downloadopensim-SC-e8acb49fefc0e567510b4058b6571599a0158b62.zip
opensim-SC-e8acb49fefc0e567510b4058b6571599a0158b62.tar.gz
opensim-SC-e8acb49fefc0e567510b4058b6571599a0158b62.tar.bz2
opensim-SC-e8acb49fefc0e567510b4058b6571599a0158b62.tar.xz
* For your fragging desire, damage enabled land works, but watch out!, life does not regenerate until you're dead!
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs56
1 files changed, 55 insertions, 1 deletions
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 6a50336..453c18f 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -67,6 +67,9 @@ namespace OpenSim.Region.Environment.Scenes
67 private LLVector3 m_requestedSitOffset = new LLVector3(); 67 private LLVector3 m_requestedSitOffset = new LLVector3();
68 private float m_sitAvatarHeight = 2.0f; 68 private float m_sitAvatarHeight = 2.0f;
69 private float m_godlevel = 0; 69 private float m_godlevel = 0;
70
71 private bool m_invulnerable = true;
72
70 private LLVector3 m_LastChildAgentUpdatePosition = new LLVector3(); 73 private LLVector3 m_LastChildAgentUpdatePosition = new LLVector3();
71 74
72 private int m_perfMonMS = 0; 75 private int m_perfMonMS = 0;
@@ -83,6 +86,7 @@ namespace OpenSim.Region.Environment.Scenes
83 private bool m_newForce = false; 86 private bool m_newForce = false;
84 private bool m_newCoarseLocations = true; 87 private bool m_newCoarseLocations = true;
85 private bool m_gotAllObjectsInScene = false; 88 private bool m_gotAllObjectsInScene = false;
89 private float m_health = 100f;
86 90
87 private LLVector3 m_lastVelocity = LLVector3.Zero; 91 private LLVector3 m_lastVelocity = LLVector3.Zero;
88 92
@@ -183,6 +187,11 @@ namespace OpenSim.Region.Environment.Scenes
183 set { m_updateflag = value; } 187 set { m_updateflag = value; }
184 get { return m_updateflag; } 188 get { return m_updateflag; }
185 } 189 }
190 public bool Invulnerable
191 {
192 set { m_invulnerable = value; }
193 get { return m_invulnerable; }
194 }
186 195
187 private readonly ulong m_regionHandle; 196 private readonly ulong m_regionHandle;
188 197
@@ -334,6 +343,11 @@ namespace OpenSim.Region.Environment.Scenes
334 get { return m_parentID; } 343 get { return m_parentID; }
335 set { m_parentID = value; } 344 set { m_parentID = value; }
336 } 345 }
346 public float Health
347 {
348 get { return m_health; }
349 set { m_health = value; }
350 }
337 351
338 /// <summary> 352 /// <summary>
339 /// These are the region handles known by the avatar. 353 /// These are the region handles known by the avatar.
@@ -602,6 +616,7 @@ namespace OpenSim.Region.Environment.Scenes
602 { 616 {
603 m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); 617 m_scene.PhysicsScene.RemoveAvatar(PhysicsActor);
604 m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; 618 m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients;
619 m_physicsActor.UnSubscribeEvents();
605 m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; 620 m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate;
606 PhysicsActor = null; 621 PhysicsActor = null;
607 } 622 }
@@ -1894,16 +1909,55 @@ namespace OpenSim.Region.Environment.Scenes
1894 } 1909 }
1895 //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; 1910 //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
1896 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; 1911 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
1912 m_physicsActor.SubscribeEvents(1000);
1897 m_physicsActor.LocalID = LocalId; 1913 m_physicsActor.LocalID = LocalId;
1898 } 1914 }
1899 1915
1900 // Event called by the physics plugin to tell the avatar about a collision. 1916 // Event called by the physics plugin to tell the avatar about a collision.
1901 private void PhysicsCollisionUpdate(EventArgs e) 1917 private void PhysicsCollisionUpdate(EventArgs e)
1902 { 1918 {
1919 if (e == null)
1920 return;
1921 CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
1922 Dictionary<uint, float> coldata = collisionData.m_objCollisionList;
1923 float starthealth = Health;
1924 uint killerObj = 0;
1925 foreach (uint localid in coldata.Keys)
1926 {
1927 if (coldata[localid] <= 0.10f || m_invulnerable)
1928 continue;
1929 //if (localid == 0)
1930 //continue;
1931
1932 Health -= coldata[localid] * 5;
1933
1934 if (Health <= 0)
1935 {
1936 if (localid != 0)
1937 killerObj = localid;
1938 }
1939 //m_log.Debug("[AVATAR]: Collision with localid: " + localid.ToString() + " at depth: " + coldata[localid].ToString());
1940 }
1941 //Health = 100;
1942 if (!m_invulnerable)
1943 {
1944 if (starthealth != Health)
1945 {
1946 ControllingClient.SendHealth(Health);
1947 }
1948 if (m_health <= 0)
1949 m_scene.EventManager.TriggerAvatarKill(killerObj, this);
1950 }
1951
1952
1903 bool isUserMoving = Velocity.X > 0 || Velocity.Y > 0; 1953 bool isUserMoving = Velocity.X > 0 || Velocity.Y > 0;
1904 UpdateMovementAnimations(isUserMoving); 1954 UpdateMovementAnimations(isUserMoving);
1905 } 1955 }
1906 1956 public void setHealthWithUpdate(float health)
1957 {
1958 Health = health;
1959 ControllingClient.SendHealth(Health);
1960 }
1907 internal void Close() 1961 internal void Close()
1908 { 1962 {
1909 lock (m_attachments) 1963 lock (m_attachments)