2016-03-01 15:47:10 +00:00
|
|
|
/*
|
|
|
|
** a_skies.cpp
|
|
|
|
** Skybox-related actors
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 1998-2006 Randy Heit
|
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "actor.h"
|
|
|
|
#include "a_sharedglobal.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "p_lnspec.h"
|
|
|
|
#include "r_sky.h"
|
2016-09-21 22:48:22 +00:00
|
|
|
#include "r_state.h"
|
2016-04-20 17:20:11 +00:00
|
|
|
#include "portal.h"
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// arg0 = Visibility*4 for this skybox
|
|
|
|
|
2016-11-05 17:27:14 +00:00
|
|
|
IMPLEMENT_CLASS(ASkyViewpoint, false, false, false)
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// If this actor has no TID, make it the default sky box
|
|
|
|
void ASkyViewpoint::BeginPlay ()
|
|
|
|
{
|
|
|
|
Super::BeginPlay ();
|
|
|
|
|
2016-04-20 17:20:11 +00:00
|
|
|
if (tid == 0 && sectorPortals[0].mSkybox == nullptr)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-04-20 17:20:11 +00:00
|
|
|
sectorPortals[0].mSkybox = this;
|
|
|
|
sectorPortals[0].mDestination = Sector;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASkyViewpoint::Destroy ()
|
|
|
|
{
|
|
|
|
// remove all sector references to ourselves.
|
2016-04-20 17:20:11 +00:00
|
|
|
for (auto &s : sectorPortals)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-06-01 08:10:18 +00:00
|
|
|
if (s.mSkybox == this)
|
|
|
|
{
|
|
|
|
s.mSkybox = 0;
|
|
|
|
// This is necessary to entirely disable EE-style skyboxes
|
|
|
|
// if their viewpoint gets deleted.
|
|
|
|
s.mFlags |= PORTSF_SKYFLATONLY;
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-04-20 17:20:11 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
Super::Destroy();
|
|
|
|
}
|
|
|
|
|
2016-11-05 17:27:14 +00:00
|
|
|
IMPLEMENT_CLASS(ASkyCamCompat, false, false, false)
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
void ASkyCamCompat::BeginPlay()
|
|
|
|
{
|
|
|
|
// Do not call the SkyViewpoint's super method because it would trash our setup
|
|
|
|
AActor::BeginPlay();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// arg0 = tid of matching SkyViewpoint
|
|
|
|
// A value of 0 means to use a regular stretched texture, in case
|
|
|
|
// there is a default SkyViewpoint in the level.
|
|
|
|
//
|
|
|
|
// arg1 = 0: set both floor and ceiling skybox
|
|
|
|
// = 1: set only ceiling skybox
|
|
|
|
// = 2: set only floor skybox
|
|
|
|
|
|
|
|
class ASkyPicker : public AActor
|
|
|
|
{
|
|
|
|
DECLARE_CLASS (ASkyPicker, AActor)
|
|
|
|
public:
|
|
|
|
void PostBeginPlay ();
|
|
|
|
};
|
|
|
|
|
2016-11-05 17:27:14 +00:00
|
|
|
IMPLEMENT_CLASS(ASkyPicker, false, false, false)
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
void ASkyPicker::PostBeginPlay ()
|
|
|
|
{
|
|
|
|
ASkyViewpoint *box;
|
|
|
|
Super::PostBeginPlay ();
|
|
|
|
|
|
|
|
if (args[0] == 0)
|
|
|
|
{
|
|
|
|
box = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TActorIterator<ASkyViewpoint> iterator (args[0]);
|
|
|
|
box = iterator.Next ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (box == NULL && args[0] != 0)
|
|
|
|
{
|
2016-04-20 17:20:11 +00:00
|
|
|
Printf ("Can't find SkyViewpoint %d for sector %td\n", args[0], Sector - sectors);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-20 17:20:11 +00:00
|
|
|
int boxindex = P_GetSkyboxPortal(box);
|
2016-05-03 17:42:53 +00:00
|
|
|
// Do not override special portal types, only regular skies.
|
2016-03-01 15:47:10 +00:00
|
|
|
if (0 == (args[1] & 2))
|
|
|
|
{
|
2016-05-03 17:42:53 +00:00
|
|
|
if (Sector->GetPortalType(sector_t::ceiling) == PORTS_SKYVIEWPOINT)
|
|
|
|
Sector->Portals[sector_t::ceiling] = boxindex;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
if (0 == (args[1] & 1))
|
|
|
|
{
|
2016-05-03 17:42:53 +00:00
|
|
|
if (Sector->GetPortalType(sector_t::floor) == PORTS_SKYVIEWPOINT)
|
|
|
|
Sector->Portals[sector_t::floor] = boxindex;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Destroy ();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Stacked sectors.
|
|
|
|
|
|
|
|
// arg0 = opacity of plane; 0 = invisible, 255 = fully opaque
|
|
|
|
|
2016-11-05 17:27:14 +00:00
|
|
|
IMPLEMENT_CLASS(AStackPoint, false, false, false)
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
void AStackPoint::BeginPlay ()
|
|
|
|
{
|
|
|
|
// Skip SkyViewpoint's initialization
|
|
|
|
AActor::BeginPlay ();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class ASectorSilencer : public AActor
|
|
|
|
{
|
|
|
|
DECLARE_CLASS (ASectorSilencer, AActor)
|
|
|
|
public:
|
|
|
|
void BeginPlay ();
|
|
|
|
void Destroy ();
|
|
|
|
};
|
|
|
|
|
2016-11-05 17:27:14 +00:00
|
|
|
IMPLEMENT_CLASS(ASectorSilencer, false, false, false)
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
void ASectorSilencer::BeginPlay ()
|
|
|
|
{
|
|
|
|
Super::BeginPlay ();
|
|
|
|
Sector->Flags |= SECF_SILENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASectorSilencer::Destroy ()
|
|
|
|
{
|
2016-09-23 06:49:30 +00:00
|
|
|
if (Sector != nullptr)
|
|
|
|
{
|
|
|
|
Sector->Flags &= ~SECF_SILENT;
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
Super::Destroy ();
|
|
|
|
}
|
|
|
|
|
|
|
|
class ASectorFlagSetter : public AActor
|
|
|
|
{
|
|
|
|
DECLARE_CLASS (ASectorFlagSetter, AActor)
|
|
|
|
public:
|
|
|
|
void BeginPlay ();
|
|
|
|
};
|
|
|
|
|
2016-11-05 17:27:14 +00:00
|
|
|
IMPLEMENT_CLASS(ASectorFlagSetter, false, false, false)
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
void ASectorFlagSetter::BeginPlay ()
|
|
|
|
{
|
|
|
|
Super::BeginPlay ();
|
|
|
|
Sector->Flags |= args[0];
|
|
|
|
}
|
|
|
|
|