Ticket #3952: simulationVariations.2.diff
File simulationVariations.2.diff, 11.5 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 575 if (this.entities.length) 576 cmpVisual.SelectAnimation("garrisoned", false, 1.0, ""); 577 else 578 cmpVisual.SelectAnimation("idle", false, 1.0, ""); 572 let selection = this.entities.length ? "garrisoned" : "ungarrisoned"; 573 cmpVisual.SetVariantSelection("garrison", selection); 579 574 }; 580 575 581 576 /** -
source/graphics/Unit.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 … … 77 77 m_Animation->SetEntityID(id); 78 78 } 79 79 80 void CUnit::SetEntitySelection(const CStr& selection)80 void CUnit::SetEntitySelection(const CStr& key, const CStr& selection) 81 81 { 82 82 CStr selection_lc = selection.LowerCase(); 83 83 84 // If we've already selected this, don't do anything 85 if (m_EntitySelections.find(selection_lc) != m_EntitySelections.end()) 84 if (m_EntitySelections[key] == selection_lc) 86 85 return; 86 m_EntitySelections[key] = selection_lc; 87 87 88 // Just allow one selection at a time 89 m_EntitySelections.clear(); 90 m_EntitySelections.insert(selection_lc); 88 ReloadObject(); 89 } 91 90 91 void CUnit::SetEntitySelection(const std::map<CStr, CStr>& selections) 92 { 93 for (const std::pair<CStr, CStr>& s : selections) 94 m_EntitySelections[s.first] = s.second.LowerCase(); 95 92 96 ReloadObject(); 93 97 } 94 98 … … 100 104 101 105 void CUnit::ReloadObject() 102 106 { 107 std::set<CStr> entitySelections; 108 for (const std::pair<CStr, CStr>& selection : m_EntitySelections) 109 entitySelections.insert(selection.second); 110 // TODO: push world selections (seasons, etc) (and reload whenever they're changed) 103 111 std::vector<std::set<CStr> > selections; 104 // TODO: push world selections (seasons, etc) (and reload whenever they're changed) 105 selections.push_back(m_EntitySelections); 112 selections.push_back(entitySelections); 106 113 selections.push_back(m_ActorSelections); 107 114 108 115 // randomly select any remain selections necessary to completely identify a variation (e.g., the new selection -
source/graphics/Unit.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 … … 64 64 void UpdateModel(float frameTime); 65 65 66 66 // Sets the entity-selection, and updates the unit to use the new 67 // actor variation. 68 void SetEntitySelection(const CStr& selection); 67 // actor variation. Either set one key at a time, or a complete map. 68 void SetEntitySelection(const CStr& key, const CStr& selection); 69 void SetEntitySelection(const std::map<CStr, CStr>& selections); 69 70 70 71 // Most units have a hopefully-unique ID number, so they can be referred to 71 72 // persistently despite saving/loading maps. Default for new units is -1; should … … 95 96 // actor-level selections for this unit 96 97 std::set<CStr> m_ActorSelections; 97 98 // entity-level selections for this unit 98 std:: set<CStr> m_EntitySelections;99 std::map<CStr, CStr> m_EntitySelections; 99 100 100 101 // object manager which looks after this unit's objectentry 101 102 CObjectManager& m_ObjectManager; -
source/simulation2/components/CCmpRallyPointRenderer.cpp
556 556 557 557 CmpPtr<ICmpVisual> cmpVisualActor(GetSimContext(), m_MarkerEntityIds[i]); 558 558 if (cmpVisualActor) 559 cmpVisualActor->Set UnitEntitySelection(CStrW(cmpPlayer->GetCiv()).ToUTF8());559 cmpVisualActor->SetVariantSelection("civ", CStrW(cmpPlayer->GetCiv()).ToUTF8()); 560 560 } 561 561 m_LastMarkerCount = m_RallyPoints.size() - 1; 562 562 } -
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" … … 80 82 fixed m_AnimDesync; 81 83 fixed m_AnimSyncRepeatTime; // 0.0 if not synced 82 84 85 std::map<CStr, CStr> m_VariantSelections; 86 83 87 u32 m_Seed; // seed used for random variations 84 88 85 89 bool m_ConstructionPreview; … … 229 233 serialize.NumberFixed_Unbounded("anim desync", m_AnimDesync); 230 234 serialize.NumberFixed_Unbounded("anim sync repeat time", m_AnimSyncRepeatTime); 231 235 236 SerializeMap<SerializeString, SerializeString>()(serialize, "variation", m_VariantSelections); 237 232 238 serialize.NumberU32_Unbounded("seed", m_Seed); 233 // TODO: variation/selection strings234 239 serialize.String("actor", m_ActorName, 0, 256); 235 240 236 241 // TODO: store actor variables? … … 259 264 // If we serialized a different seed or different actor, reload actor 260 265 if (oldSeed != GetActorSeed() || m_BaseActorName != m_ActorName) 261 266 ReloadActor(); 267 else 268 m_Unit->SetEntitySelection(m_VariantSelections); 262 269 263 270 fixed repeattime = m_AnimSyncRepeatTime; // save because SelectAnimation overwrites it 264 271 … … 410 417 return CVector3D(); 411 418 } 412 419 420 virtual void SetVariantSelection(const CStr& key, const CStr& selection) 421 { 422 m_VariantSelections[key] = selection; 423 if (!m_Unit) 424 return; 425 m_Unit->SetEntitySelection(key, selection); 426 } 427 413 428 virtual void SelectAnimation(const std::string& name, bool once, fixed speed, const std::wstring& soundgroup) 414 429 { 415 430 m_AnimRunThreshold = fixed::Zero(); … … 422 437 423 438 if (m_Unit) 424 439 { 425 m_Unit->SetEntitySelection(m_AnimName);440 SetVariantSelection("animation", m_AnimName); 426 441 if (m_Unit->GetAnimation()) 427 442 m_Unit->GetAnimation()->SetAnimationState(m_AnimName, m_AnimOnce, m_AnimSpeed.ToFloat(), m_AnimDesync.ToFloat(), m_SoundGroup.c_str()); 428 443 } … … 440 455 m_AnimOverride.erase(name); 441 456 } 442 457 443 virtual void SetUnitEntitySelection(const CStr& selection)444 {445 if (m_Unit)446 {447 m_Unit->SetEntitySelection(selection);448 }449 }450 451 458 virtual void SelectMovementAnimation(fixed runThreshold) 452 459 { 453 460 m_AnimRunThreshold = runThreshold; … … 454 461 455 462 if (m_Unit) 456 463 { 457 m_Unit->SetEntitySelection("walk");464 SetVariantSelection("animation", "walk"); 458 465 if (m_Unit->GetAnimation()) 459 466 m_Unit->GetAnimation()->SetAnimationState("walk", false, 1.f, 0.f, L""); 460 467 } … … 713 720 714 721 InitModel(node->GetChild("VisualActor")); 715 722 716 m_Unit->SetEntitySelection(m_AnimName); 723 m_Unit->SetEntitySelection(m_VariantSelections); 724 717 725 if (m_Unit->GetAnimation()) 718 726 m_Unit->GetAnimation()->SetAnimationState(m_AnimName, m_AnimOnce, m_AnimSpeed.ToFloat(), m_AnimDesync.ToFloat(), m_SoundGroup.c_str()); 719 727 … … 763 771 if (it != m_AnimOverride.end()) 764 772 name = it->second; 765 773 766 m_Unit->SetEntitySelection(name);767 if ( speed == 0.0f)774 SetVariantSelection("animation", name); 775 if (m_Unit->GetAnimation()) 768 776 { 769 m_Unit->SetEntitySelection(name); 770 if (m_Unit->GetAnimation()) 777 if (speed == 0.0f) 771 778 m_Unit->GetAnimation()->SetAnimationState(name, false, 1.f, 0.f, L""); 772 } 773 else 774 { 775 m_Unit->SetEntitySelection(name); 776 if (m_Unit->GetAnimation()) 779 else 777 780 m_Unit->GetAnimation()->SetAnimationState(name, false, speed, 0.f, L""); 778 781 } 779 782 } -
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_2("SetVariantSelection", void, ICmpVisual, SetVariantSelection, CStr, CStr) 25 26 DEFINE_INTERFACE_METHOD_4("SelectAnimation", void, ICmpVisual, SelectAnimation, std::string, bool, fixed, std::wstring) 26 27 DEFINE_INTERFACE_METHOD_1("SelectMovementAnimation", void, ICmpVisual, SelectMovementAnimation, fixed) 27 28 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 * Set the variant selection of the actor for a certain key 84 */ 85 virtual void SetVariantSelection(const CStr& key, const CStr& selection) = 0; 86 87 /** 83 88 * Start playing the given animation. If there are multiple possible animations then it will 84 89 * pick one at random (not network-synchronised). 85 90 * If @p soundgroup is specified, then the sound will be played at each 'event' point in the … … 107 112 virtual void ResetMoveAnimation(const std::string& name) = 0; 108 113 109 114 /** 110 * Sets the specified entity selection on the underlying unit.111 */112 virtual void SetUnitEntitySelection(const CStr& selection) = 0;113 114 /**115 115 * Start playing the walk/run animations, scaled to the unit's movement speed. 116 116 * @param runThreshold movement speed at which to switch to the run animation 117 117 */