public void Init(Godot.Collections.Dictionary fields) { _fields = fields; Connect("area_entered", this, "_on_area_entered"); Connect("area_exited", this, "_on_area_exited"); string nodeName = this.Name; // example: entity_entity_316_brush_brush_0_trigger string entityName = nodeName.Substring(("entity_").Length); entityName = entityName.Substring(("entity_").Length); entityName = "entity_" + entityName.Substring(0, entityName.Find("_", 0)); // link doors to mesh _mesh = GetNode("/root/Initial/Map/QodotMap/Meshes/" + entityName) as MeshInstance; // link doors to collision Godot.Collections.Array collisions = (GetNode("/root/Initial/Map/QodotMap/Collision/Static Collision") as StaticBody).GetChildren(); foreach (CollisionShape cs in collisions) { if (cs.Name.Contains(entityName)) { _collisions.Add(cs); } } foreach (DictionaryEntry kvp in fields) { string val = kvp.Value.ToString(); switch (kvp.Key.ToString().ToLower()) { case "allowteams": string teamVal = val; if (teamVal.Contains("blue")) { _allowTeams.Add(1); } if (teamVal.Contains("red")) { _allowTeams.Add(2); } if (teamVal.Contains("yellow")) { _allowTeams.Add(3); } if (teamVal.Contains("green")) { _allowTeams.Add(4); } break; case "team_no": _allowTeams.Add(Convert.ToInt16(val)); break; case "lip": _lip = (float)Convert.ToDouble(val); _lip = _lip / 10; break; case "angle": _angle = (float)Convert.ToDouble(val); break; case "dmg": _damage = (float)Convert.ToDouble(val); break; case "speed": _speed = (float)Convert.ToDouble(val); _speed = _speed / 10; break; case "sounds": int type = Convert.ToInt16(val); SetupSound(type); break; case "wait": _wait = (float)Convert.ToDouble(val); break; } } AABB boundingBox = _mesh.GetAabb(); _closeLocation = GlobalTransform.origin; _lastPos = _closeLocation; _destination = _closeLocation; _openLocation = GlobalTransform.origin; // -1 is up // -2 is down // 0 and above are horizontal if (_angle == -1) { _openLocation.y -= (boundingBox.Size.y - _lip); } else if (_angle == -2) { _openLocation.y += (boundingBox.Size.y - _lip); } else { // FIXME until we run into something that uses it, we just assume full x or z bounding box float moveDist = 0f; if (_angle == 90f || _angle == 270f) { moveDist = boundingBox.Size.x - _lip; } else { moveDist = boundingBox.Size.z - _lip; } Spatial moveNode = new Spatial(); AddChild(moveNode); moveNode.RotateY(Mathf.Deg2Rad(_angle)); moveNode.Translate(new Vector3(0, 0, moveDist)); _openLocation = moveNode.GlobalTransform.origin; } }
public AABB GetAABB() { return(_mesh.GetAabb()); }