Merge branch 'master' into Importer

This commit is contained in:
William Moberg
2016-03-14 01:09:18 +01:00
15 changed files with 3975 additions and 3836 deletions
+1 -1
Submodule assets updated: 2c75d24ddf...b6027bf49f
@@ -32,6 +32,8 @@ private:
glm::vec3 m_LastPosition = glm::vec3(); glm::vec3 m_LastPosition = glm::vec3();
// Used to track afterimages for sprint effect. // Used to track afterimages for sprint effect.
float m_SprintEffectTimer; float m_SprintEffectTimer;
// Used to track afterimages for dash effect.
float m_DashEffectTimer;
// The logic for making the sound play when player is moving // The logic for making the sound play when player is moving
void playerStep(double dt, EntityWrapper player); void playerStep(double dt, EntityWrapper player);
// Spawn a hexagon at origin of an Entity // Spawn a hexagon at origin of an Entity
+1 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<BoostAssault xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BoostAssault.xsd"> <BoostAssault xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BoostAssault.xsd">
<StrengthOfEffect>2</StrengthOfEffect> <StrengthOfEffect>1.35</StrengthOfEffect>
</BoostAssault> </BoostAssault>
@@ -10,8 +10,8 @@
<MaxTravelAngle>0.174533</MaxTravelAngle> <!-- 0.174533 = 10 degrees --> <MaxTravelAngle>0.174533</MaxTravelAngle> <!-- 0.174533 = 10 degrees -->
<NumPellets>9</NumPellets> <NumPellets>9</NumPellets>
<RPM>120</RPM> <RPM>120</RPM>
<ViewPunch>0.03</ViewPunch> <ViewPunch>0.15</ViewPunch>
<ViewReturnSpeed>0.2</ViewReturnSpeed> <ViewReturnSpeed>0.3</ViewReturnSpeed>
<ReloadTime>0.5</ReloadTime> <ReloadTime>0.5</ReloadTime>
<TriggerHeld>false</TriggerHeld> <TriggerHeld>false</TriggerHeld>
<FireCooldown>0</FireCooldown> <FireCooldown>0</FireCooldown>
+1
View File
@@ -3,5 +3,6 @@
<FadeTime>1</FadeTime> <FadeTime>1</FadeTime>
<Time>0</Time> <Time>0</Time>
<Out>true</Out> <Out>true</Out>
<Loop>true</Loop>
<Reverse>false</Reverse> <Reverse>false</Reverse>
</Fade> </Fade>
+3
View File
@@ -11,6 +11,9 @@
<xs:element name="Out" type="t:bool" minOccurs="0"> <xs:element name="Out" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>If the entity should fade out or in.</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>If the entity should fade out or in.</xs:documentation></xs:annotation>
</xs:element> </xs:element>
<xs:element name="Loop" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>If the effect should loop when it is done.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Reverse" type="t:bool" minOccurs="0"> <xs:element name="Reverse" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>If the entity should reverse the fade after finishing, this will double the speed.</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>If the entity should reverse the fade after finishing, this will double the speed.</xs:documentation></xs:annotation>
</xs:element> </xs:element>
@@ -6,7 +6,9 @@
<BaseDamage>20</BaseDamage> <BaseDamage>20</BaseDamage>
<RPM>500</RPM> <RPM>500</RPM>
<Automatic>false</Automatic> <Automatic>false</Automatic>
<ViewPunch>0.01</ViewPunch> <ViewPunch>0.05</ViewPunch>
<MaxTravelAngle>0.174533</MaxTravelAngle> <!-- 0.174533 = 10 degrees -->
<ViewReturnSpeed>0.2</ViewReturnSpeed>
<ReloadTime>1.0</ReloadTime> <ReloadTime>1.0</ReloadTime>
<EquipTime>0.5</EquipTime> <EquipTime>0.5</EquipTime>
<TriggerHeld>false</TriggerHeld> <TriggerHeld>false</TriggerHeld>
@@ -14,4 +16,5 @@
<ReloadQueued>false</ReloadQueued> <ReloadQueued>false</ReloadQueued>
<IsReloading>false</IsReloading> <IsReloading>false</IsReloading>
<ReloadTimer>0</ReloadTimer> <ReloadTimer>0</ReloadTimer>
<CurrentTravel>0</CurrentTravel>
</SidearmWeapon> </SidearmWeapon>
@@ -36,6 +36,12 @@
<xs:element name="ViewPunch" type="t:float" minOccurs="0"> <xs:element name="ViewPunch" type="t:float" minOccurs="0">
<xs:annotation><xs:documentation>View punch in radians for each shell fired</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>View punch in radians for each shell fired</xs:documentation></xs:annotation>
</xs:element> </xs:element>
<xs:element name="MaxTravelAngle" type="t:float" minOccurs="0">
<xs:annotation><xs:documentation>Maximum vertical aim travel angle in radians</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="ViewReturnSpeed" type="t:float" minOccurs="0">
<xs:annotation><xs:documentation>The speed in radians per second the view returns to its original position after being punched</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="ReloadTime" type="t:double" minOccurs="0"> <xs:element name="ReloadTime" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>Time it takes to load ONE SHELL into the weapon in seconds</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>Time it takes to load ONE SHELL into the weapon in seconds</xs:documentation></xs:annotation>
</xs:element> </xs:element>
@@ -47,6 +53,7 @@
<xs:element name="ReloadQueued" type="t:bool" minOccurs="0"/> <xs:element name="ReloadQueued" type="t:bool" minOccurs="0"/>
<xs:element name="IsReloading" type="t:bool" minOccurs="0"/> <xs:element name="IsReloading" type="t:bool" minOccurs="0"/>
<xs:element name="ReloadTimer" type="t:double" minOccurs="0"/> <xs:element name="ReloadTimer" type="t:double" minOccurs="0"/>
<xs:element name="CurrentTravel" type="t:float" minOccurs="0"/>
</xs:all> </xs:all>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
-13
View File
@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="DashEffect" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Lifetime>
<Lifetime>0.5</Lifetime>
</c:Lifetime>
<c:Transform/>
</Components>
<Children/>
</Entity>
File diff suppressed because it is too large Load Diff
+75 -39
View File
@@ -34,7 +34,7 @@
<Axis X="0" Y="1" Z="0"/> <Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter> </c:RaptorCopter>
<c:Transform> <c:Transform>
<Orientation X="0" Y="98.9142075" Z="0"/> <Orientation X="0" Y="214.830872" Z="0"/>
</c:Transform> </c:Transform>
</Components> </Components>
<Children> <Children>
@@ -46,7 +46,7 @@
</c:RaptorCopter> </c:RaptorCopter>
<c:Transform> <c:Transform>
<Position X="0" Y="26" Z="40"/> <Position X="0" Y="26" Z="40"/>
<Orientation X="0" Y="-114.726761" Z="0"/> <Orientation X="0" Y="-346.565979" Z="0"/>
</c:Transform> </c:Transform>
</Components> </Components>
<Children> <Children>
@@ -92,42 +92,6 @@
<c:Transform/> <c:Transform/>
</Components> </Components>
<Children> <Children>
<Entity name="ButtonCorner_Origin">
<Components>
<c:Transform/>
</Components>
<Children>
<Entity name="TopRight">
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture>
</c:Sprite>
<c:Transform>
<Position X="0.0970000029" Y="0.0220000017" Z="0.00499999989"/>
<Scale X="0.00499999989" Y="0.00499999989" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="BottomRight">
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture>
</c:Sprite>
<c:Transform>
<Position X="0.0970000029" Y="-0.0219999999" Z="0.00499999989"/>
<Orientation X="0" Y="0" Z="4.71199989"/>
<Scale X="0.00499999989" Y="0.00499999989" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="Button_1"> <Entity name="Button_1">
<Components> <Components>
<c:Button/> <c:Button/>
@@ -149,6 +113,44 @@
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
<Entity name="ButtonCorner_Origin">
<Components>
<c:Transform/>
</Components>
<Children>
<Entity name="BottomRight">
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture>
<Linear>false</Linear>
</c:Sprite>
<c:Transform>
<Position X="0.0970000029" Y="-0.0219999999" Z="0.00499999989"/>
<Orientation X="0" Y="0" Z="4.71199989"/>
<Scale X="0.00499999989" Y="0.00499999989" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="TopRight">
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture>
<Linear>false</Linear>
</c:Sprite>
<c:Transform>
<Position X="0.0970000029" Y="0.0220000017" Z="0.00499999989"/>
<Scale X="0.00499999989" Y="0.00499999989" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="Text"> <Entity name="Text">
<Components> <Components>
<c:Text> <c:Text>
@@ -218,6 +220,7 @@
<Model>Models/Core/UnitQuad.mesh</Model> <Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap> <GlowMap></GlowMap>
<DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture> <DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture>
<Linear>false</Linear>
</c:Sprite> </c:Sprite>
<c:Transform> <c:Transform>
<Position X="0.0970000029" Y="-0.0219999999" Z="0.00499999989"/> <Position X="0.0970000029" Y="-0.0219999999" Z="0.00499999989"/>
@@ -233,6 +236,7 @@
<Model>Models/Core/UnitQuad.mesh</Model> <Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap> <GlowMap></GlowMap>
<DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture> <DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture>
<Linear>false</Linear>
</c:Sprite> </c:Sprite>
<c:Transform> <c:Transform>
<Position X="0.0970000029" Y="0.0220000017" Z="0.00499999989"/> <Position X="0.0970000029" Y="0.0220000017" Z="0.00499999989"/>
@@ -263,6 +267,7 @@
<Model>Models/Core/UnitQuad.mesh</Model> <Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap> <GlowMap></GlowMap>
<DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture> <DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture>
<Linear>false</Linear>
</c:Sprite> </c:Sprite>
<c:Transform> <c:Transform>
<Position X="0.0970000029" Y="0.0220000017" Z="0.00499999989"/> <Position X="0.0970000029" Y="0.0220000017" Z="0.00499999989"/>
@@ -277,6 +282,7 @@
<Model>Models/Core/UnitQuad.mesh</Model> <Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap> <GlowMap></GlowMap>
<DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture> <DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture>
<Linear>false</Linear>
</c:Sprite> </c:Sprite>
<c:Transform> <c:Transform>
<Position X="0.0970000029" Y="-0.0219999999" Z="0.00499999989"/> <Position X="0.0970000029" Y="-0.0219999999" Z="0.00499999989"/>
@@ -299,6 +305,10 @@
<BlurBackground>true</BlurBackground> <BlurBackground>true</BlurBackground>
<Color A="0.392156869" B="0" G="0" R="0"/> <Color A="0.392156869" B="0" G="0" R="0"/>
</c:Sprite> </c:Sprite>
<c:InputCmdButton>
<Command>Options</Command>
<PressValue>1</PressValue>
</c:InputCmdButton>
<c:Transform> <c:Transform>
<Scale X="0.200000003" Y="0.0500000007" Z="1"/> <Scale X="0.200000003" Y="0.0500000007" Z="1"/>
</c:Transform> </c:Transform>
@@ -308,7 +318,7 @@
<Entity name="Text"> <Entity name="Text">
<Components> <Components>
<c:Text> <c:Text>
<Content>Option</Content> <Content>Options</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource> <Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment> <Alignment>
<Right/> <Right/>
@@ -374,6 +384,7 @@
<Model>Models/Core/UnitQuad.mesh</Model> <Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap> <GlowMap></GlowMap>
<DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture> <DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture>
<Linear>false</Linear>
</c:Sprite> </c:Sprite>
<c:Transform> <c:Transform>
<Position X="0.0970000029" Y="-0.0219999999" Z="0.00499999989"/> <Position X="0.0970000029" Y="-0.0219999999" Z="0.00499999989"/>
@@ -389,6 +400,7 @@
<Model>Models/Core/UnitQuad.mesh</Model> <Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap> <GlowMap></GlowMap>
<DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture> <DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture>
<Linear>false</Linear>
</c:Sprite> </c:Sprite>
<c:Transform> <c:Transform>
<Position X="0.0970000029" Y="0.0220000017" Z="0.00499999989"/> <Position X="0.0970000029" Y="0.0220000017" Z="0.00499999989"/>
@@ -419,12 +431,36 @@
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
<Entity name="OptionsSpawner">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/OptionMenu.xml</EntityFile>
</c:Spawner>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children> </Children>
</Entity> </Entity>
</Children> </Children>
</Entity> </Entity>
</Children> </Children>
</Entity> </Entity>
<Entity name="TitleSprite">
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Test/SmallDiff.png</DiffuseTexture>
<ClampToBorder>true</ClampToBorder>
</c:Sprite>
<c:Transform>
<Position X="0.0320000015" Y="0.0220000017" Z="-0.0550000034"/>
<Scale X="0.0500000007" Y="0.0150000006" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children> </Children>
</Entity> </Entity>
</Children> </Children>
+2 -2
View File
@@ -24,14 +24,14 @@ void FadeSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cFade,
currentTime += dTime; currentTime += dTime;
if(currentTime > fadeTime) { if(currentTime > fadeTime) {
currentTime = 0.0; currentTime = 0.0 + fadeTime * (bool)cFade["Loop"];
if ((bool)cFade["Reverse"]) { if ((bool)cFade["Reverse"]) {
(Field<bool>)cFade["Out"] = !(bool)cFade["Out"]; (Field<bool>)cFade["Out"] = !(bool)cFade["Out"];
currentTime = fadeTime; currentTime = fadeTime;
} }
} }
if(currentTime < 0.0) { if(currentTime < 0.0) {
currentTime = fadeTime; currentTime = fadeTime * (bool)cFade["Loop"];
if ((bool)cFade["Reverse"]) { if ((bool)cFade["Reverse"]) {
(Field<bool>)cFade["Out"] = !(bool)cFade["Out"]; (Field<bool>)cFade["Out"] = !(bool)cFade["Out"];
currentTime = 0.0; currentTime = 0.0;
+68 -25
View File
@@ -3,6 +3,7 @@
PlayerMovementSystem::PlayerMovementSystem(SystemParams params) PlayerMovementSystem::PlayerMovementSystem(SystemParams params)
: System(params) : System(params)
, m_SprintEffectTimer(0.f) , m_SprintEffectTimer(0.f)
, m_DashEffectTimer(0.f)
{ {
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &PlayerMovementSystem::OnPlayerSpawned); EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &PlayerMovementSystem::OnPlayerSpawned);
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &PlayerMovementSystem::OnDoubleJump); EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &PlayerMovementSystem::OnDoubleJump);
@@ -24,23 +25,57 @@ void PlayerMovementSystem::Update(double dt)
if (LocalPlayer.Valid()){ if (LocalPlayer.Valid()){
updateVelocity(LocalPlayer, dt); updateVelocity(LocalPlayer, dt);
} }
//m_SprintEffectTimer += dt;
//if (m_SprintEffectTimer < 0.016f) {
m_SprintEffectTimer += dt; // return;
if (m_SprintEffectTimer < 0.016f) { //}
//m_SprintEffectTimer = 0.f;
//auto pool = m_World->GetComponents("SprintAbility");
//if (pool == nullptr) {
// return;
//}
//for (auto cSprint : *pool) {
// if (cSprint.EntityID != LocalPlayer.ID && (bool)cSprint["Active"]) {
// // Spawn one afterimage for each player that sprints.
// EntityWrapper player(m_World, cSprint.EntityID);
// auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/SprintEffect.xml");
// EntityWrapper sprintEffect = entityFile->MergeInto(m_World);
// auto playerModel = player.FirstChildByName("PlayerModel");
// if (!playerModel.Valid()) {
// continue;
// }
// if (!playerModel.HasComponent("Model")) {
// continue;
// }
// if (!playerModel.HasComponent("Animation")) {
// continue;
// }
// auto playerEntityModel = playerModel["Model"];
// auto playerEntityAnimation = playerModel["Animation"];
// playerEntityModel.Copy(sprintEffect["Model"]);
// playerEntityAnimation.Copy(sprintEffect["Animation"]);
// sprintEffect["ExplosionEffect"]["EndColor"] = (glm::vec4)playerEntityModel["Color"];
// ((Field<glm::vec4>)sprintEffect["ExplosionEffect"]["EndColor"]).w(0.f);
// sprintEffect["Animation"]["Speed1"] = 0.0;
// sprintEffect["Animation"]["Speed2"] = 0.0;
// sprintEffect["Animation"]["Speed3"] = 0.0;
// sprintEffect["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"];
// sprintEffect["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"];
// }
//}
m_DashEffectTimer += dt;
if (m_DashEffectTimer < 0.075f) {
return; return;
} }
m_SprintEffectTimer = 0.f; m_DashEffectTimer = 0.f;
auto pool = m_World->GetComponents("SprintAbility"); auto pool = m_World->GetComponents("DashAbility");
if (pool == nullptr) { if (pool == nullptr) {
return; return;
} }
for (auto cSprint : *pool) { for (auto cDash : *pool) {
if (cSprint.EntityID != LocalPlayer.ID && (bool)cSprint["Active"]) { if (cDash.EntityID != LocalPlayer.ID && (double)cDash["CoolDownMaxTimer"] - (double)cDash["CoolDownTimer"] < 0.5) {
// Spawn one afterimage for each player that sprints. // Spawn one afterimage for each player that Dashes.
EntityWrapper player(m_World, cSprint.EntityID); EntityWrapper player(m_World, cDash.EntityID);
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/SprintEffect.xml");
EntityWrapper sprintEffect = entityFile->MergeInto(m_World);
auto playerModel = player.FirstChildByName("PlayerModel"); auto playerModel = player.FirstChildByName("PlayerModel");
if (!playerModel.Valid()) { if (!playerModel.Valid()) {
continue; continue;
@@ -48,20 +83,28 @@ void PlayerMovementSystem::Update(double dt)
if (!playerModel.HasComponent("Model")) { if (!playerModel.HasComponent("Model")) {
continue; continue;
} }
if (!playerModel.HasComponent("Animation")) { EntityWrapper dashEffect = playerModel.Clone();
continue; for (auto& cAnim : dashEffect.ChildrenWithComponent("Animation")) {
cAnim["Animation"]["Play"] = false;
} }
auto playerEntityModel = playerModel["Model"]; const double fadeTime = 0.5f;
auto playerEntityAnimation = playerModel["Animation"]; for (auto& cModel : dashEffect.ChildrenWithComponent("Model")) {
playerEntityModel.Copy(sprintEffect["Model"]); EntityWrapper e(m_World, cModel.ID);
playerEntityAnimation.Copy(sprintEffect["Animation"]); e.AttachComponent("Lifetime");
sprintEffect["ExplosionEffect"]["EndColor"] = (glm::vec4)playerEntityModel["Color"]; e.AttachComponent("Fade");
((Field<glm::vec4>)sprintEffect["ExplosionEffect"]["EndColor"]).w(0.f); e["Fade"]["Loop"] = false;
sprintEffect["Animation"]["Speed1"] = 0.0; e["Fade"]["FadeTime"] = fadeTime;
sprintEffect["Animation"]["Speed2"] = 0.0; e["Fade"]["Time"] = fadeTime;
sprintEffect["Animation"]["Speed3"] = 0.0; e["Lifetime"]["Lifetime"] = fadeTime;
sprintEffect["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"]; }
sprintEffect["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"]; dashEffect.AttachComponent("Lifetime");
dashEffect.AttachComponent("Fade");
dashEffect["Fade"]["Loop"] = false;
dashEffect["Fade"]["FadeTime"] = fadeTime;
dashEffect["Fade"]["Time"] = fadeTime;
dashEffect["Lifetime"]["Lifetime"] = fadeTime;
dashEffect["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"];
dashEffect["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"];
} }
} }
} }
@@ -324,23 +324,23 @@ void DefenderWeaponBehaviour::fireShell(ComponentWrapper cWeapon, WeaponInfo& wi
spawnTracers(cWeapon, wi, pattern); spawnTracers(cWeapon, wi, pattern);
// View punch // View punch
//if (IsClient) { if (IsClient) {
// EntityWrapper camera = wi.Player.FirstChildByName("Camera"); EntityWrapper camera = wi.Player.FirstChildByName("Camera");
// if (camera.Valid()) { if (camera.Valid()) {
// glm::vec3& cameraOrientation = camera["Transform"]["Orientation"]; Field<glm::vec3> cameraOrientation = camera["Transform"]["Orientation"];
// float viewPunch = cWeapon["ViewPunch"]; float viewPunch = cWeapon["ViewPunch"];
// float maxTravelAngle = cWeapon["MaxTravelAngle"]; float maxTravelAngle = (const float&)cWeapon["MaxTravelAngle"];
// float& currentTravel = cWeapon["CurrentTravel"]; Field<float> currentTravel = cWeapon["CurrentTravel"];
// if (currentTravel < maxTravelAngle) { if (currentTravel < maxTravelAngle) {
// float change = viewPunch; float change = viewPunch;
// if (currentTravel + change > maxTravelAngle) { if (currentTravel + change > maxTravelAngle) {
// change = maxTravelAngle - currentTravel; change = maxTravelAngle - currentTravel;
// } }
// cameraOrientation.x += change; cameraOrientation.x(cameraOrientation.x() + change);
// currentTravel += change; currentTravel += change;
// } }
// } }
//} }
// Play animation // Play animation
playAnimationAndReturn(wi.FirstPersonEntity, "FinalBlend", "Fire"); playAnimationAndReturn(wi.FirstPersonEntity, "FinalBlend", "Fire");
@@ -69,6 +69,21 @@ void SidearmWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo&
} }
} }
// Restore view angle
if (IsClient) {
Field<float> currentTravel = cWeapon["CurrentTravel"];
Field<float> returnSpeed = cWeapon["ViewReturnSpeed"];
if (currentTravel > 0) {
float change = returnSpeed * dt;
currentTravel = glm::max(0.f, currentTravel - change);
EntityWrapper camera = wi.Player.FirstChildByName("Camera");
if (camera.Valid()) {
Field<glm::vec3> cameraOrientation = camera["Transform"]["Orientation"];
cameraOrientation.x(cameraOrientation.x() - change);
}
}
}
if ((bool)cWeapon["Automatic"] && canFire(cWeapon)) { if ((bool)cWeapon["Automatic"] && canFire(cWeapon)) {
fireBullet(cWeapon, wi); fireBullet(cWeapon, wi);
} }
@@ -183,6 +198,25 @@ void SidearmWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi
magAmmo -= 1; magAmmo -= 1;
} }
// View punch
if (IsClient) {
EntityWrapper camera = wi.Player.FirstChildByName("Camera");
if (camera.Valid()) {
Field<glm::vec3> cameraOrientation = camera["Transform"]["Orientation"];
float viewPunch = cWeapon["ViewPunch"];
float maxTravelAngle = cWeapon["MaxTravelAngle"];
Field<float> currentTravel = cWeapon["CurrentTravel"];
if (currentTravel < maxTravelAngle) {
float change = viewPunch;
if (currentTravel + change > maxTravelAngle) {
change = maxTravelAngle - currentTravel;
}
cameraOrientation.x(cameraOrientation.x() + change);
currentTravel += change;
}
}
}
// Get weapon model based on current person // Get weapon model based on current person
EntityWrapper weaponModelEntity = getRelevantWeaponEntity(wi); EntityWrapper weaponModelEntity = getRelevantWeaponEntity(wi);
if (!weaponModelEntity.Valid()) { if (!weaponModelEntity.Valid()) {