3 * Iter Vehemens ad Necem (IVAN)
4 * Copyright (C) Timo Kiviluoto
5 * Released under the GNU General
8 * See LICENSING which should be included
9 * along with this file for more details
13 /* Compiled through areaset.cpp */
15 square::square(area
* AreaUnder
, v2 Pos
) : AreaUnder(AreaUnder
), Character(0), Pos(Pos
), Luminance(0), Flags(IS_TRANSPARENT
|MEMORIZED_UPDATE_REQUEST
|DESCRIPTION_CHANGE
), StaticAnimatedEntities(0), AnimatedEntities(0), LastSeen(0) { }
19 character
* Char
= GetCharacter();
23 for(int c
= 0; c
< Char
->GetSquaresUnder(); ++c
)
24 Char
->GetSquareUnder(c
)->Character
= 0;
30 void square::Save(outputfile
& SaveFile
) const
32 if(!Character
|| Character
->IsMainPos(Pos
))
33 SaveFile
<< Character
;
35 SaveFile
<< StaticAnimatedEntities
<< AnimatedEntities
<< MemorizedDescription
;
38 void square::Load(inputfile
& SaveFile
)
41 SaveFile
>> Character
;
43 SaveFile
>> StaticAnimatedEntities
>> AnimatedEntities
>> MemorizedDescription
;
46 void square::AddCharacter(character
* Guy
)
49 Flags
|= STRONG_NEW_DRAW_REQUEST
;
52 IncAnimatedEntities();
57 void square::RemoveCharacter()
59 if(Character
&& Character
->IsAnimated())
60 DecAnimatedEntities();
63 Flags
|= STRONG_NEW_DRAW_REQUEST
;
66 cchar
* square::SurviveMessage(character
* Char
) const
68 if(GetOTerrain() && !Char
->CanMoveOn(GetOTerrain()))
69 return GetOTerrain()->SurviveMessage();
71 return GetGTerrain()->SurviveMessage();
74 cchar
* square::MonsterSurviveMessage(character
* Char
) const
76 if(GetOTerrain() && !Char
->CanMoveOn(GetOTerrain()))
77 return GetOTerrain()->MonsterSurviveMessage();
79 return GetGTerrain()->MonsterSurviveMessage();
82 cchar
* square::DeathMessage(character
* Char
) const
84 if(GetOTerrain() && !Char
->CanMoveOn(GetOTerrain()))
85 return GetOTerrain()->DeathMessage();
87 return GetGTerrain()->DeathMessage();
90 cchar
* square::MonsterDeathVerb(character
* Char
) const
92 if(GetOTerrain() && !Char
->CanMoveOn(GetOTerrain()))
93 return GetOTerrain()->MonsterDeathVerb();
95 return GetGTerrain()->MonsterDeathVerb();
98 cchar
* square::ScoreEntry(character
* Char
) const
100 if(GetOTerrain() && !Char
->CanMoveOn(GetOTerrain()))
101 return GetOTerrain()->ScoreEntry();
103 return GetGTerrain()->ScoreEntry();
106 truth
square::IsFatalToStay() const
108 return GetGTerrain()->IsFatalToStay() || (GetOTerrain() && GetOTerrain()->IsFatalToStay());
111 int square::GetEntryDifficulty() const
113 return GetGTerrain()->GetEntryDifficulty();
116 int square::GetRestModifier() const
118 return GetOTerrain() ? GetOTerrain()->GetRestModifier() : 1;
121 truth
square::CanBeSeenBy(ccharacter
* Who
, truth IgnoreDarkness
) const
124 return CanBeSeenByPlayer(IgnoreDarkness
);
126 return CanBeSeenFrom(Who
->GetPos(), Who
->GetLOSRangeSquare(), IgnoreDarkness
);
129 void square::SurviveEffect(character
* Who
)
132 GetOTerrain()->SurviveEffect(Who
);
134 GetGTerrain()->SurviveEffect(Who
);
137 square
* square::GetNeighbourSquare(int I
) const
139 return AreaUnder
->GetNeighbourSquare(Pos
, I
);
142 square
* square::GetNearSquare(v2 Pos
) const
144 return AreaUnder
->GetSquare(Pos
);