Ticket #3952: simulationVariations.diff
File simulationVariations.diff, 6.3 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/art/actors/structures/hellenes/siege_tower.xml
17 17 </variant> 18 18 </group> 19 19 <group> 20 <variant frequency="1 00" name="Idle"/>20 <variant frequency="1" name="ungarrisoned"/> 21 21 <variant name="garrisoned"> 22 22 <props> 23 23 <prop actor="props/special/common/waypoint_flag_0ad.xml" attachpoint="garrisoned"/> 24 24 </props> 25 25 </variant> 26 </group> 27 <group> 28 <variant frequency="1" name="alive"/> 26 29 <variant name="death"> 27 30 <props> 28 31 <prop attachpoint="garrisoned"/> -
binaries/data/mods/public/simulation/components/GarrisonHolder.js
566 566 567 567 GarrisonHolder.prototype.UpdateGarrisonFlag = function() 568 568 { 569 varcmpVisual = Engine.QueryInterface(this.entity, IID_Visual);569 let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); 570 570 if (!cmpVisual) 571 571 return; 572 cmpVisual.SelectAnimation("garrisoned", true, 0, ""); 573 // TODO: ought to extend ICmpVisual to let us just select variant 574 // keywords without changing the animation too 572 let oldVariant = "garrisoned"; 573 let newVariant = "garrisoned"; 575 574 if (this.entities.length) 576 cmpVisual.SelectAnimation("garrisoned", false, 1.0, "");575 oldVariant = "ungarrisoned"; 577 576 else 578 cmpVisual.SelectAnimation("idle", false, 1.0, ""); 577 newVariant = "ungarrisoned"; 578 579 let selections = cmpVisual.GetVariantSelections(); 580 cmpVisual.SetVariantSelections(selections.map(s => s == oldVariant ? newVariant : s)) 579 581 }; 580 582 581 583 /** -
source/simulation2/components/CCmpVisualActor.cpp
1 /* Copyright (C) 201 4Wildfire Games.1 /* Copyright (C) 2016 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 32 32 #include "ICmpValueModificationManager.h" 33 33 #include "ICmpVisibility.h" 34 34 35 #include "simulation2/serialization/SerializeTemplates.h" 36 35 37 #include "graphics/Decal.h" 36 38 #include "graphics/Frustum.h" 37 39 #include "graphics/Model.h" … … 230 232 serialize.NumberFixed_Unbounded("anim sync repeat time", m_AnimSyncRepeatTime); 231 233 232 234 serialize.NumberU32_Unbounded("seed", m_Seed); 233 // TODO: variation/selection strings234 235 serialize.String("actor", m_ActorName, 0, 256); 235 236 236 237 // TODO: store actor variables? … … 246 247 } 247 248 248 249 SerializeCommon(serialize); 250 251 std::vector<std::string> variantSelections = GetVariantSelections(); 252 SerializeVector<SerializeString>()(serialize, "variantSeletions", variantSelections); 249 253 } 250 254 251 255 virtual void Deserialize(const CParamNode& paramNode, IDeserializer& deserialize) … … 269 273 270 274 SetAnimationSyncRepeat(repeattime); 271 275 276 std::vector<std::string> variantSelections; 277 SerializeVector<SerializeString>()(deserialize, "variantSeletions", variantSelections); 278 SetVariantSelections(variantSelections); 279 272 280 if (m_Unit) 273 281 { 274 282 CmpPtr<ICmpOwnership> cmpOwnership(GetEntityHandle()); … … 410 418 return CVector3D(); 411 419 } 412 420 421 virtual std::vector<std::string> GetVariantSelections() 422 { 423 std::vector<std::string> result; 424 if (!m_Unit) 425 return result; 426 std::set<CStr> selections = m_Unit->GetActorSelections(); 427 std::copy(selections.begin(), selections.end(), std::back_inserter(result)); 428 return result; 429 } 430 431 virtual void SetVariantSelections(const std::vector<std::string>& selections) 432 { 433 if (!m_Unit) 434 return; 435 std::set<CStr> result(selections.begin(), selections.end()); 436 m_Unit->SetActorSelections(result); 437 } 438 413 439 virtual void SelectAnimation(const std::string& name, bool once, fixed speed, const std::wstring& soundgroup) 414 440 { 415 441 m_AnimRunThreshold = fixed::Zero(); -
source/simulation2/components/ICmpVisual.cpp
1 /* Copyright (C) 201 3Wildfire Games.1 /* Copyright (C) 2016 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 22 22 #include "simulation2/system/InterfaceScripted.h" 23 23 24 24 BEGIN_INTERFACE_WRAPPER(Visual) 25 DEFINE_INTERFACE_METHOD_0("GetVariantSelections", std::vector<std::string>, ICmpVisual, GetVariantSelections) 26 DEFINE_INTERFACE_METHOD_1("SetVariantSelections", void, ICmpVisual, SetVariantSelections, std::vector<std::string>) 25 27 DEFINE_INTERFACE_METHOD_4("SelectAnimation", void, ICmpVisual, SelectAnimation, std::string, bool, fixed, std::wstring) 26 28 DEFINE_INTERFACE_METHOD_1("SelectMovementAnimation", void, ICmpVisual, SelectMovementAnimation, fixed) 27 29 DEFINE_INTERFACE_METHOD_1("ResetMoveAnimation", void, ICmpVisual, ResetMoveAnimation, std::string) -
source/simulation2/components/ICmpVisual.h
1 /* Copyright (C) 201 3Wildfire Games.1 /* Copyright (C) 2016 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 80 80 virtual CUnit* GetUnit() = 0; 81 81 82 82 /** 83 * Get the variant selections of the actor 84 */ 85 virtual std::vector<std::string> GetVariantSelections() = 0; 86 87 /** 88 * Set the variant selections of the actor 89 */ 90 virtual void SetVariantSelections(const std::vector<std::string>& selections) = 0; 91 92 /** 83 93 * Start playing the given animation. If there are multiple possible animations then it will 84 94 * pick one at random (not network-synchronised). 85 95 * If @p soundgroup is specified, then the sound will be played at each 'event' point in the