/// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnPostCreate(Boolean)"/>.</summary> protected override void OnPostCreate(bool loaded) { base.OnPostCreate(loaded); if (EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle()) { const string regionTypeName = "ManualInfluenceRegion"; InfluenceRegionType regionType = (InfluenceRegionType)EntityTypes.Instance.GetByName( regionTypeName); if (regionType == null) { regionType = (InfluenceRegionType)EntityTypes.Instance.ManualCreateType( regionTypeName, EntityTypes.Instance.GetClassInfoByEntityClassName("InfluenceRegion")); regionType.NetworkType = EntityNetworkTypes.ServerOnly; } region = (InfluenceRegion)Entities.Instance.Create(regionType, Map.Instance); region.ShapeType = Region.ShapeTypes.Capsule; region.DistanceFunction = InfluenceRegion.DistanceFunctionType.NormalFadeAxisX; region.SetTransform(Position, Rotation, InfluenceRegionScale); region.PostCreate(); region.AllowSave = false; region.EditorSelectable = false; bladesMotor = PhysicsModel.GetMotor("bladesMotor") as GearedMotor; } SubscribeToTickEvent(); }
/// <summary>Overridden from <see cref="Engine.MapSystem.MapObject.OnSetTransform(ref Vec3,ref Quat,ref Vec3)"/>.</summary> protected override void OnSetTransform(ref Vec3 pos, ref Quat rot, ref Vec3 scl) { base.OnSetTransform(ref pos, ref rot, ref scl); if (region != null) { region.SetTransform(Position, Rotation, InfluenceRegionScale); } }
void UpdateTransform() { if (region == null) { return; } float len = Type.Length * throttle; Vec3 size = new Vec3(len, Type.Thickness, Type.Thickness); region.SetTransform(Position + Rotation * new Vec3(size.X * .5f, 0, 0), Rotation, size); }