public Entity AddBounds(UnityEngine.Bounds newBounds) { var component = new BoundsComponent(); component.bounds = newBounds; return(AddBounds(component)); }
public Entity ReplaceBounds(UnityEngine.Bounds newBounds) { BoundsComponent component; if (hasBounds) { WillRemoveComponent(ComponentIds.Bounds); component = bounds; } else { component = new BoundsComponent(); } component.bounds = newBounds; return ReplaceComponent(ComponentIds.Bounds, component); }
public Entity ReplaceBounds(UnityEngine.Bounds newBounds) { BoundsComponent component; if (hasBounds) { WillRemoveComponent(ComponentIds.Bounds); component = bounds; } else { component = new BoundsComponent(); } component.bounds = newBounds; return(ReplaceComponent(ComponentIds.Bounds, component)); }
public Entity AddBounds(BoundsComponent component) { return(AddComponent(ComponentIds.Bounds, component)); }
public Entity AddBounds(UnityEngine.Bounds newBounds) { var component = new BoundsComponent(); component.bounds = newBounds; return AddBounds(component); }
public Entity AddBounds(BoundsComponent component) { return AddComponent(ComponentIds.Bounds, component); }
public static Actor FromStartingLocation(H2vMap map, ScenarioTag.AiSquadDefinition.StartingLocation loc) { var entity = new Actor(); entity.FriendlyName = loc.Description; var charIndex = loc.CharacterIndex; if (charIndex == ushort.MaxValue) { charIndex = map.Scenario.AiSquadDefinitions[loc.SquadIndex].CharacterIndex; } if (charIndex == ushort.MaxValue) { throw new Exception("Couldn't determine character to create"); } var character = map.GetTag(map.Scenario.CharacterDefinitions[charIndex].CharacterReference); if (map.TryGetTag <BaseTag>(character.Unit, out var unit) == false) { return(entity); } TagRef <HaloModelTag> model = default; if (unit is BipedTag biped) { model = biped.Model; } else if (unit is VehicleTag vehicle) { model = vehicle.Hlmt; } var comp = new RenderModelComponent(entity, new Model <BitmapTag> { Note = $"[{unit.Id}] {unit.Name}", Flags = ModelFlags.Diffuse | ModelFlags.CastsShadows | ModelFlags.ReceivesShadows, Meshes = MeshFactory.GetRenderModel(map, model) }); var boneComp = new RenderModelComponent(entity, new Model <BitmapTag> { Note = $"[{unit.Id}] {unit.Name} Bones", Flags = ModelFlags.Wireframe, Meshes = MeshFactory.GetBonesModel(map, model), RenderLayer = RenderLayers.Debug }); var orientation = Quaternion.CreateFromAxisAngle(EngineGlobals.Up, loc.Rotation); var xform = new TransformComponent(entity, loc.Position, orientation); // TODO: add back var body = PhysicsComponentFactory.CreateDynamicRigidBody(entity, xform, map, model); var comOffset = Vector3.Zero; if (map.TryGetTag(model, out var hlmt) && map.TryGetTag(hlmt.PhysicsModel, out var phmo) && phmo.BodyParameters.Length > 0) { comOffset = phmo.BodyParameters[0].CenterOfMass; } var centerOfMass = new BoundsComponent(entity, comOffset - new Vector3(0.02f), comOffset + new Vector3(0.02f), new Vector4(1f, 1f, 0, 1f)); var origin = new BoundsComponent(entity, new Vector3(-0.02f), new Vector3(0.02f), new Vector4(0, 1f, 0, 1f)); var originalTag = new OriginalTagComponent(entity, loc); entity.SetComponents(xform, comp, boneComp, centerOfMass, origin, originalTag); return(entity); }