mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
move locking behaviour to cellref
This commit is contained in:
parent
85d52ec183
commit
7c8b82f45c
@ -181,7 +181,7 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager ()->messageBox (keyName + " #{sKeyUsed}");
|
MWBase::Environment::get().getWindowManager ()->messageBox (keyName + " #{sKeyUsed}");
|
||||||
if(isLocked)
|
if(isLocked)
|
||||||
unlock(ptr);
|
ptr.getCellRef().unlock();
|
||||||
// using a key disarms the trap
|
// using a key disarms the trap
|
||||||
if(isTrapped)
|
if(isTrapped)
|
||||||
{
|
{
|
||||||
|
@ -162,7 +162,7 @@ namespace MWClass
|
|||||||
if(actor == MWMechanics::getPlayer())
|
if(actor == MWMechanics::getPlayer())
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox(keyName + " #{sKeyUsed}");
|
MWBase::Environment::get().getWindowManager()->messageBox(keyName + " #{sKeyUsed}");
|
||||||
if(isLocked)
|
if(isLocked)
|
||||||
unlock(ptr); //Call the function here. because that makes sense.
|
ptr.getCellRef().unlock(); //Call the function here. because that makes sense.
|
||||||
// using a key disarms the trap
|
// using a key disarms the trap
|
||||||
if(isTrapped)
|
if(isTrapped)
|
||||||
{
|
{
|
||||||
|
@ -1150,7 +1150,7 @@ namespace MWMechanics
|
|||||||
store.remove(*it, toMove, player);
|
store.remove(*it, toMove, player);
|
||||||
}
|
}
|
||||||
// TODO: unhardcode the locklevel
|
// TODO: unhardcode the locklevel
|
||||||
targetContainer.getClass().lock(targetContainer,50);
|
targetContainer.getCellRef().lock(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MechanicsManager::itemTaken(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item, const MWWorld::Ptr& container,
|
void MechanicsManager::itemTaken(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item, const MWWorld::Ptr& container,
|
||||||
|
@ -50,7 +50,7 @@ namespace MWMechanics
|
|||||||
{
|
{
|
||||||
if (Misc::Rng::roll0to99() <= x)
|
if (Misc::Rng::roll0to99() <= x)
|
||||||
{
|
{
|
||||||
lock.getClass().unlock(lock);
|
lock.getCellRef().unlock();
|
||||||
resultMessage = "#{sLockSuccess}";
|
resultMessage = "#{sLockSuccess}";
|
||||||
resultSound = "Open Lock";
|
resultSound = "Open Lock";
|
||||||
mActor.getClass().skillUsageSucceeded(mActor, ESM::Skill::Security, 1);
|
mActor.getClass().skillUsageSucceeded(mActor, ESM::Skill::Security, 1);
|
||||||
|
@ -696,7 +696,7 @@ namespace MWMechanics
|
|||||||
{
|
{
|
||||||
if (caster == getPlayer())
|
if (caster == getPlayer())
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicLockSuccess}");
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicLockSuccess}");
|
||||||
target.getClass().lock(target, static_cast<int>(magnitude));
|
target.getCellRef().lock(static_cast<int>(magnitude));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -716,7 +716,7 @@ namespace MWMechanics
|
|||||||
if (caster == getPlayer())
|
if (caster == getPlayer())
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicOpenSuccess}");
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicOpenSuccess}");
|
||||||
}
|
}
|
||||||
target.getClass().unlock(target);
|
target.getCellRef().unlock();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D(target, "Open Lock Fail", 1.f, 1.f);
|
MWBase::Environment::get().getSoundManager()->playSound3D(target, "Open Lock Fail", 1.f, 1.f);
|
||||||
|
@ -182,7 +182,7 @@ namespace MWScript
|
|||||||
runtime.pop();
|
runtime.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr.getClass().lock (ptr, lockLevel);
|
ptr.getCellRef().lock (lockLevel);
|
||||||
|
|
||||||
// Instantly reset door to closed state
|
// Instantly reset door to closed state
|
||||||
// This is done when using Lock in scripts, but not when using Lock spells.
|
// This is done when using Lock in scripts, but not when using Lock spells.
|
||||||
@ -202,7 +202,7 @@ namespace MWScript
|
|||||||
{
|
{
|
||||||
MWWorld::Ptr ptr = R()(runtime);
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
ptr.getClass().unlock (ptr);
|
ptr.getCellRef().unlock ();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -225,6 +225,19 @@ namespace MWWorld
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CellRef::lock(int lockLevel)
|
||||||
|
{
|
||||||
|
if(lockLevel != 0)
|
||||||
|
setLockLevel(abs(lockLevel)); //Changes lock to locklevel, if positive
|
||||||
|
else
|
||||||
|
setLockLevel(ESM::UnbreakableLock); // If zero, set to max lock level
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellRef::unlock()
|
||||||
|
{
|
||||||
|
setLockLevel(-abs(mCellRef.mLockLevel)); //Makes lockLevel negative
|
||||||
|
}
|
||||||
|
|
||||||
std::string CellRef::getKey() const
|
std::string CellRef::getKey() const
|
||||||
{
|
{
|
||||||
return mCellRef.mKey;
|
return mCellRef.mKey;
|
||||||
|
@ -99,6 +99,8 @@ namespace MWWorld
|
|||||||
// For an unlocked door, it is set to -(previous locklevel)
|
// For an unlocked door, it is set to -(previous locklevel)
|
||||||
int getLockLevel() const;
|
int getLockLevel() const;
|
||||||
void setLockLevel(int lockLevel);
|
void setLockLevel(int lockLevel);
|
||||||
|
void lock(int lockLevel);
|
||||||
|
void unlock();
|
||||||
// Key and trap ID names, if any
|
// Key and trap ID names, if any
|
||||||
std::string getKey() const;
|
std::string getKey() const;
|
||||||
std::string getTrap() const;
|
std::string getTrap() const;
|
||||||
|
@ -144,20 +144,6 @@ namespace MWWorld
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Class::lock (const Ptr& ptr, int lockLevel) const
|
|
||||||
{
|
|
||||||
if(lockLevel != 0)
|
|
||||||
ptr.getCellRef().setLockLevel(abs(lockLevel)); //Changes lock to locklevel, if positive
|
|
||||||
else
|
|
||||||
ptr.getCellRef().setLockLevel(ESM::UnbreakableLock); // If zero, set to max lock level
|
|
||||||
}
|
|
||||||
|
|
||||||
void Class::unlock (const Ptr& ptr) const
|
|
||||||
{
|
|
||||||
int lockLevel = ptr.getCellRef().getLockLevel();
|
|
||||||
ptr.getCellRef().setLockLevel(-abs(lockLevel)); //Makes lockLevel negative
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Class::canLock(const ConstPtr &ptr) const
|
bool Class::canLock(const ConstPtr &ptr) const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -163,12 +163,6 @@ namespace MWWorld
|
|||||||
virtual bool hasInventoryStore (const Ptr& ptr) const;
|
virtual bool hasInventoryStore (const Ptr& ptr) const;
|
||||||
///< Does this object have an inventory store, i.e. equipment slots? (default implementation: false)
|
///< Does this object have an inventory store, i.e. equipment slots? (default implementation: false)
|
||||||
|
|
||||||
virtual void lock (const Ptr& ptr, int lockLevel) const;
|
|
||||||
///< Lock object (default implementation: throw an exception)
|
|
||||||
|
|
||||||
virtual void unlock (const Ptr& ptr) const;
|
|
||||||
///< Unlock object (default implementation: throw an exception)
|
|
||||||
|
|
||||||
virtual bool canLock (const ConstPtr& ptr) const;
|
virtual bool canLock (const ConstPtr& ptr) const;
|
||||||
|
|
||||||
virtual void setRemainingUsageTime (const Ptr& ptr, float duration) const;
|
virtual void setRemainingUsageTime (const Ptr& ptr, float duration) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user